Skip to content

Commit

Permalink
Fixes to make files always private.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Sung committed Aug 10, 2020
1 parent 8e88cdc commit c4fc14f
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/main/java/gyro/google/GoogleStorageFileBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.google.cloud.storage.StorageOptions;
import com.psddev.dari.util.ObjectUtils;
import gyro.core.FileBackend;
import gyro.core.FileBackendAccess;
import gyro.core.GyroCore;
import gyro.core.GyroException;
import gyro.core.Type;
Expand Down Expand Up @@ -88,10 +87,10 @@ public InputStream openInput(String file) throws Exception {
}

@Override
public OutputStream openOutput(String file, FileBackendAccess acl) throws Exception {
public OutputStream openOutput(String file) throws Exception {
return Channels.newOutputStream(service().writer(
BlobInfo.newBuilder(getBucket(), prefixed(file)).build(),
Storage.BlobWriteOption.predefinedAcl(predefinedAcl(acl))));
Storage.BlobWriteOption.predefinedAcl(Storage.PredefinedAcl.PRIVATE)));
}

@Override
Expand All @@ -105,13 +104,14 @@ public boolean exists(String file) throws Exception {
}

@Override
public void copy(String source, String destination, FileBackendAccess acl) throws Exception {
public void copy(String source, String destination) throws Exception {
String bucket = getBucket();
service().copy(Storage.CopyRequest.newBuilder()
.setSource(bucket, prefixed(source))
.setTarget(
BlobInfo.newBuilder(bucket, prefixed(destination)).build(),
Storage.BlobTargetOption.predefinedAcl(predefinedAcl(acl)))

Storage.BlobTargetOption.predefinedAcl(Storage.PredefinedAcl.PRIVATE))
.build()).getResult();
}

Expand Down Expand Up @@ -140,13 +140,4 @@ private String removePrefix(String file) {

return file;
}

private Storage.PredefinedAcl predefinedAcl(FileBackendAccess acl) {
Storage.PredefinedAcl predefinedAcl = Storage.PredefinedAcl.PRIVATE;

if (acl == FileBackendAccess.PUBLIC) {
predefinedAcl = Storage.PredefinedAcl.PUBLIC_READ;
}
return predefinedAcl;
}
}

0 comments on commit c4fc14f

Please sign in to comment.