amplify-js: Amplify v6: It is not possible to set boundaries in REST requests with multipart

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

REST API

Amplify Categories

api

Environment information

# Put output below this line

  "dependencies": {
    ...,
    "@aws-amplify/api-rest": "^4.0.5",
    "@aws-amplify/auth": "^6.0.5",
    "@aws-amplify/ui-react": "^6.0.3",
  },

Describe the bug

When i try to submit a Rest request that contains Multipart the framework sets Content-Type to multipart/form-data and it prevents the creatorin of boundary

Content-Type: multipart/form-data; boundary=---------------------------3513053024223207799458523308

https://github.com/aws-amplify/amplify-js/blob/a353e0d777a1ca5e57aa4b2cda48d147ee1d4803/packages/api-rest/src/apis/common/handler.ts#L54

This is a change compared to the v.5.X version.

Am i missing something? Is there any documentation about this change?

Expected behavior

Implement the same behavior that we had with the previous version

Reproduction steps

const form = new FormData(); form.append(parameterName, new Blob([file], { type: file.type }), file.name); post({ apiName, path, options: { body: form } }).response.body.json();

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 3
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Hi @AllanZhengYP

I can confirm the same as @dvalbuena1

Best

Hi @AllanZhengYP I just tested 6.0.8 and 6.0.9-unstable.58ed2f7.0 and the 6.0.9 version worked! It is setting the boundary correctly. 6.0.8 version did not.

In the meantime, it is save to use that 6.0.9 version, right?

HI @svidgen

With the following configuration, this was working

"@aws-amplify/api-rest": "^3.5.6",
"@aws-amplify/auth": "^5.6.6",
"@aws-amplify/ui-react": "^5.3.2",

After the following upgrade, it is not possible to upload files with REST API

"@aws-amplify/api-rest": "4.0.7",
"@aws-amplify/auth": "6.0.7",
"@aws-amplify/ui-react": "6.0.6",

Authentication is against AWS Cognito

Best

Same issue here. When trying to upload a file via API REST, looks like V6 is not setting the boundary as mentioned by @kingferiol

In fact, when comparing the requests through Dev tools the boundary is missing in V6: V5: image

V6: image