Skip to content

Commit

Permalink
fix: added necessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
“sneha122” committed Apr 25, 2024
1 parent a2cf527 commit 3316290
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/client/src/pages/Editor/APIEditor/PostBodyData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ function PostBodyData(props: Props) {
/>
</JSONEditorFieldWrapper>
);
// This format is particularly used for uploading files, in this case
// From filepicker we can take base64 string and pass it to server
// which then decodes it and uploads the file to given URL
case POST_BODY_FORMAT_OPTIONS.BINARY:
return (
<JSONEditorFieldWrapper key={key}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,15 @@ public String parseFormData(List<Property> bodyFormData, Boolean encodeParamsTog
}

public BodyInserter<?, ?> parseMultimediaData(String requestBodyObj) {
// This decoding for base64 is required because of
// issue https://github.com/appsmithorg/appsmith/issues/32378
// According to this if we tried to upload any multimedia files (img, audio, video)
// It was not getting decoded before uploading on required URL
if (requestBodyObj.contains(BASE64_DELIMITER)) {
List<String> bodyArrayList = Arrays.asList(requestBodyObj.split(BASE64_DELIMITER));
requestBodyObj = bodyArrayList.get(bodyArrayList.size() - 1);

// Using mimeDecoder here, since base64 conversion by file picker widget follows mime standard
byte[] payload = Base64.getMimeDecoder().decode(bodyArrayList.get(bodyArrayList.size() - 1));
return BodyInserters.fromValue(payload);
}
Expand Down

0 comments on commit 3316290

Please sign in to comment.