PromucFlow_constructor/app/server/appsmith-plugins
sneha122 5f2a9ef387
fix: REST API multimedia file upload issue fixed (#32921)
## 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: 3316290a4d7d77ae3f9d8969245c5f470ef1ab5c
> 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”>
2024-04-29 17:08:33 +05:30
..
amazons3Plugin fix: commands title changed to command for each datasource query editor forms (#32526) 2024-04-10 17:05:01 +05:30
anthropicPlugin feat: Vision models support in Anthropic (#32103) 2024-04-16 13:41:28 +00:00
appsmithAiPlugin chore: Add after delete hook for Appsmith AI datasource (#31466) 2024-03-19 12:52:32 +05:30
arangoDBPlugin fix: reverting the default port numbers for the datasources (#32726) 2024-04-17 13:44:18 +05:30
awsLambdaPlugin fix: commands title changed to command for each datasource query editor forms (#32526) 2024-04-10 17:05:01 +05:30
databricksPlugin fix: Making userTag a hidden field to not expose it as a user configurable option with Appsmith being the default value (#31792) 2024-03-14 16:18:44 +05:30
dynamoPlugin chore: Applied Spotless formatter (#25173) 2023-07-07 00:43:11 +05:30
elasticSearchPlugin fix: reverting the default port numbers for the datasources (#32726) 2024-04-17 13:44:18 +05:30
firestorePlugin fix: firestore pagination issue (#32912) 2024-04-29 11:23:34 +05:30
googleAiPlugin fix: commands title changed to command for each datasource query editor forms (#32526) 2024-04-10 17:05:01 +05:30
googleSheetsPlugin fix: graphQL bindings issue resolved (#32760) 2024-04-18 17:36:54 +05:30
graphqlPlugin ci: Publish port 4200 for TED (#32835) 2024-04-22 10:33:07 +05:30
jsPlugin chore: Applied Spotless formatter (#25173) 2023-07-07 00:43:11 +05:30
mongoPlugin fix: graphQL bindings issue resolved (#32760) 2024-04-18 17:36:54 +05:30
mssqlPlugin fix: reverting the default port numbers for the datasources (#32726) 2024-04-17 13:44:18 +05:30
mysqlPlugin fix: graphQL bindings issue resolved (#32760) 2024-04-18 17:36:54 +05:30
openAiPlugin chore: Fix warnings on @EqualsAndHashCode (#32667) 2024-04-15 13:46:37 +05:30
oraclePlugin fix: reverting the default port numbers for the datasources (#32726) 2024-04-17 13:44:18 +05:30
postgresPlugin fix: reverting the default port numbers for the datasources (#32726) 2024-04-17 13:44:18 +05:30
redisPlugin fix: reverting the default port numbers for the datasources (#32726) 2024-04-17 13:44:18 +05:30
redshiftPlugin fix: reverting the default port numbers for the datasources (#32726) 2024-04-17 13:44:18 +05:30
restApiPlugin fix: REST API multimedia file upload issue fixed (#32921) 2024-04-29 17:08:33 +05:30
saasPlugin fix: graphQL bindings issue resolved (#32760) 2024-04-18 17:36:54 +05:30
smtpPlugin fix: reverting the default port numbers for the datasources (#32726) 2024-04-17 13:44:18 +05:30
snowflakePlugin feat: Add isSuggested value to templates for all plugins (#26623) 2023-08-30 11:49:25 +01:00
pom.xml test: Add AssertJ for plugins, for better assertions (#31380) 2024-03-04 07:33:45 +05:30