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.

1 Like

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:


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