Set proper mime type for Google Cloud Bucket upload

When uploading a file to a GCP bucket, the file type options are VERY limited. Based on the connector settings only “JSON”, “CSV”, and “BINARY” are available and this cannot be set via code when calling the connector. Having a specific file type for a connector is really limiting.

My feature request is to add an “AUTO” option for the file type. Google Cloud is pretty good at determining a file type and setting it’s Content-Type (i.e. type in Google console) upon upload. This is at least our experience writing against GCP directly with its SDK.

Our use case with Retool is that we are uploading image files (.jpg, .png, .svg) to Google a google bucket, and for each file we upload we have to manually run from the command line a gcloud command to update the type of that file as the Retool connector always set’s it to binary.

Please advise if this isn’t enough detail for this feature request.

Thank you.

1 Like

Thank you Brett! I’ll get this down as a feature request.

2 Likes

Any traction on this feature request?

Hey there Brett,

I currently have a PR under review to add the ability to specify custom comtent-types on GCS upload queries. Once this gets merged, you will be able to choose to either use one of the 4 presets, or switch to a free-entry field and specify your own type, similar to how you can in an S3 query currently:


1 Like

Hey, this is great, thank you. Is there any reason why auto isn’t an option? It’s been a bit, but I do recall that as an option in there api and sdk. For common files like svg’s it gets it right.

This solution means I’ll need a code to identify the extension or ask the user (which usually goes so well :stuck_out_tongue:).

Thank you for the improvement though, it does provide more options which is appreciated.

Brett

I can definitely look into the possibility of adding an "auto" option, I mostly went this route since we already had something similar with the S3 resources.

If you are using an Upload component to do the upload, you should be able to use the contentType property on the file like so (no extra logic required!):



Hey @mark ,

This Content-Type setting seems to corrupt the file.

When setting the Content-Type for an image, the image does not load, and the file size is quite different.

To reproduce:

  1. Create a fileInput component, select a png file
  2. Upload an image with binary type
  3. Upload an image with image/png type (same result as dynamically setting it with {{ fileInput1.files[0].type }}

See screenshots:

If this helps, these are the changes if I switch from Binary to image/png and inspect changes:

In addition to uploadFileType changing, useRawUploadFileType changes from false to true

Hey, @tomskopek are you running into the same issue here?

Hey @Jay,
Sorry - I'm not sure I understand your question?

Are you still seeing this Content-Type setting corrupt the file?

Hi @Jay,

I just retried this. Yes, I'm still seeing the same behaviour as when I posted earlier. Adding the content-type corrupts the file and increases the file size.

Not sure if this applies, but when I use an S3 resource, I do not specify the content-type and it has not failed so far... maybe no specification is worth trying?
I use (allowing for the uploading of multiple files) - {{fileInput2.files[i].type}}

Hi,

Was there any progress on this? Setting the content type as blank corrupts the image, setting the content type as image/png also corrupts the file. Setting the content type as binary uploads fine but the file is set to download.

For context: I need to upload an image to google cloud storage and be able to view that image's exposed link without it automatically downloading. If I drag and drop an image straight into cloud storage, it works as expected.

Hi Amanda, I was able to manage for the most part. I set the mime type on the bucket itself and I haven't faced problems ever since.
I am still waiting for the project to be moved to production. I will be sure to open a ticket once I get back to it.

Thank you for your response :slight_smile: