The ACL after uploading an object to Google Cloud Storage is overwritten each time.
I'm creating BlobInfo with preset ACL, so that the uploaded object have to be public read:
String blobId = "PUBLIC/1";
com.google.cloud.storage.BlobInfo info = com.google.cloud.storage.BlobInfo.newBuilder(RuntimeConfig.USERDATA_BUCKET_NAME, blobId)
.setContentType(mimetype)
.setMetadata(metadata)
.setAcl(new ArrayList<>(Arrays.asList(Acl.of(Acl.User.ofAllUsers(), Acl.Role.READER)))) // <-- HERE
.build();
After this I'm signing the URL, like this:
URL signedUrl = storage.signUrl(info, 30,
TimeUnit.MINUTES,
Storage.SignUrlOption.httpMethod(com.google.cloud.storage.HttpMethod.valueOf("PUT")),
Storage.SignUrlOption.withContentType());
Then, I'm uploading the file from the web and this works fine, with only one problem - there is no ACL with public read.
Of course, I can change the ACL after the upload is done, like this:
storage.createAcl(info.getBlobId(), (Acl.of(Acl.User.ofAllUsers(), Acl.Role.READER)));
But is there a way to set it directly within the signed URL, without an additional trigger from the web after having successfully uploaded it?
Thanks!