appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.52k stars 3.73k forks source link

[Bug]: Uploading image files to Google Drive from Appsmith doesn't work #26265

Open felix-appsmith opened 1 year ago

felix-appsmith commented 1 year ago

Is there an existing issue for this?

Description

I tried to do it using the V2 and V3 versions of the official Google Drive API. The authentication with OAuth2.0 is done correctly, and I can upload text files. However, when I upload images, they are uploaded apparently corrupted, since they do not show a preview of the file and when downloading they can be opened either.

1 2

When I tried the same configuration in Postman, everything went well. I could obtain the auth token to make the request and the file was uploaded successfully.

3 4

I also tried uploading the file to Dropbox and despite the response being successful (status 200), nothing was uploading to the destination folder.

5 6

Steps To Reproduce

  1. Drop a filepicker widget and edit its properties to store binary or Base64 data.

  2. Configure an Authenticated API datasource with your credentials. The URL to upload files is https://www.googleapis.com/upload/drive/v3/files.

  3. Add a new POST query. Configure uploadType = media in the Params, Content-type = {{FilePicker1.files[0].type}} in the Headers and {{FilePicker1.files[0].data}} in the Body of the request (you can also try {{FilePicker1.files[0]}}).

  4. Run the query, go to Google Drive and notice the corrupted file.

Public Sample App

No response

Environment

Production

Issue video log

No response

Version

Cloud Appsmith v1.9.32-SNAPSHOT

ame-appsmith commented 7 months ago

I reproduced a similar behavior when uploading a file via FilePicker using the Dropbox API. The file gets uploaded successfully, but when opening it or downloading it from Dropbox, it is corrupted. The API works fine with Postman and uploads the file correctly. With Appsmith, it uploads the file but it gets corrupted. The only difference between Appsmith and Postman is the Body type (see screenshots). However, the API body I used in Appsmith should be correct according to this tutorial. Furthermore, if the file is in txt format, it does not get corrupted, but for psd, png, pdf files, the behavior is reproducible. image image A link to a sample app and more details are in this Slack thread.

Nikhil-Nandagopal commented 7 months ago

@ame-appsmith did you try with the multi-part option?

ame-appsmith commented 7 months ago

@Nikhil-Nandagopal yes, I tried and got the same issue.