-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Rest API Plugin: provide option to upload binary data (multimedia files) #32378
Comments
APMU, binary data upload is completely non functional via REST API app. Reasons:
Relevant code sections:
A possible feature implementation to enable binary file upload:
|
Reasons why this could be treated as high priority issue:
|
Mentioned this in the Sprint Planning Doc for us to plan it in the Next Sprint. |
This a problem I was running into. I tried uploading a photoshop file through the file uploader to a dropbox endpoint and the resulting file gives me an error when I try to open it. Context
SummaryI upload a small photoshop file (71 KB) onto the file uploader and click upload. The triggered query, upon file upload, is a POST request to this endpoint ("https://content.dropboxapi.com/2/files/upload"). I set the data format to binary in the file uploader widget and in the query's body I refer to the uploading file as {{DropboxFilePicker.files[0].data}}. After uploading I receive a larger file in dropbox (147 KB). When I try to open the uploaded file I get the following error. |
## Description If we use REST API action and file picker widget to upload any multimedia files (image, audio, video, pdf, xlsx), The file upload would be successful but file would get corrupted upon uploading. This was happening because file picker widget encodes this file to base64 format, and we were uploading this same base64 string using REST API url. Instead we should have decoded this base64 and then uploaded the file to retain the original contents of the file. This PR fixes that issue by adding a new tab in body of the REST API action called `binary`, once we select this tab, we get autogenerated header for `Content-Type: application/octet-stream`, in this binary input field we can then provide base64 encoded file contents, the server then decodes the contents before triggering the respective REST API and uploading the file. ### Steps to test the issue 1. Add a file picker widget on canvas 2. Select data format as `Base64` 3. Upload any of pdf, image, audio, video, xlsx in file picker 4. Create a REST API action using [Dropbox upload API](https://www.dropbox.com/developers/documentation/http/documentation#files-upload) 5. Configure the API headers as mentioned in the documentation, also configure file name in the header correctly 6. Go to body tab, select binary and file contents in input box using binding like {{Filepicker1.files[0].data}} 7. Execute this API 8. Now go to your dropbox account and check the uploaded file, you should be able to successfully preview it Fixes #32378 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Datasource" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/8844375718> > Commit: 3316290 > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8844375718&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for binary file uploads in API requests, including handling of base64-encoded files. - Expanded content type options to include a new "BINARY" type for API requests. - **Tests** - Implemented new tests to verify the functionality of binary file uploads with dynamic data binding. - **Bug Fixes** - Ensured correct handling and auto-generation of headers for binary file types and form urlencoded data formats. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: “sneha122” <“sneha@appsmith.com”>
Is there an existing issue for this?
Summary
Currently REST API plugin does not seem to have any option that allows users to directly transmit binary data / file content .
e.g. Postman provides a
binary
tab:https://theappsmith.slack.com/files/U035SFJHW3A/F06S5N2BUTX/image.png
Why should this be worked on?
This should take away a lot of confusion related with file uploads using REST API query.
Front conversations
The text was updated successfully, but these errors were encountered: