Following the answer provided in this SO question by @brandon-yarbrough, I opted to use Signed URL to upload objects to cloud storage. I generate the signed URLs through google-cloud-storage
library as follows:
private static Storage storage = StorageOptions.getDefaultInstance().getService();
URL uploadUrl = storage.signUrl(
BlobInfo.newBuilder(IMAGE_BUCKET, fileName).build(),
30,
TimeUnit.MINUTES,
Storage.SignUrlOption.httpMethod(HttpMethod.PUT));
When I try to upload a file to the generated URL, I get the error below.
<?xml version='1.0' encoding='UTF-8'?>
<Error>
<Code>AccessDenied</Code>
<Message>Access denied.</Message>
<Details>Anonymous users does not have storage.objects.create access to bucket the-awesomest-bucket.</Details>
</Error>
My understanding of signed URL was that users don't need to be authenticated, and therefore allowing anonymous users to upload data without me having to set any special permissions on the bucket. Am I missing something?