Writing to google storage from image upload component

Hello,

I'm having no problem reading from a bucket in my google storage account, but when I try to write to one, I'm having some issues.

I've configured the cors policy on my bucket as follows:

    {
      "origin": ["https://{{my_organization}}.retool.com"],
      "method": ["PUT", "GET", "POST", "HEAD", "DELETE"],
      "responseHeader": ["Content-Type", "x-goog-acl"],
      "maxAgeSeconds": 3600
    }
]

The configuration for my events is as shown:

With the following trigger:

async function blobToBinaryWrapper(blobs) {
  for (let i = 0; i < blobs.length; i++) {
    let blob = blobs[i];
    
    let base64 = await utils.getDataByObjectURL(blob);
    base64 = base64.split("base64,")[1];
    upload_completion_photo.trigger(
      { 
        additionalScope: {
          imageData: base64,
          imageName: "test.jpg",
        } 
      }
    );
  }
}

blobToBinaryWrapper(completion_image_upload.value);

Any help would be much appreciated. I'm pretty stumped. I'm trying to upload photos that have been uploaded through the image upload component.

I'm getting a 400 error, which leads me to think that maybe my content type or data format is incorrect.

Resolution for all those interested: MAKE SURE you don't select an access level parameter if you don't have object by object level permissions. Leave it blank :). Everything else worked as expected.

1 Like

Thanks, @Sydney_Runkle! :tada:

1 Like

Following up -- I ended up changing the content type to application/octet-stream. This change meant that not only were my file uploads supported, but reading the files via a different query worked as well. With the default Binary content type, I was having trouble reading in the files when images were submitted from mobile devices.