aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.4k stars 2.11k forks source link

storage.put is not working when retention period is on for the s3 bucket #8675

Closed rajnikumari022 closed 11 months ago

rajnikumari022 commented 2 years ago

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Storage

Amplify Categories

storage

Environment information

``` # Put output below this line System: OS: macOS 10.15.7 CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz Memory: 26.22 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.18.2 - /usr/local/bin/node Yarn: 1.22.10 - ~/node_modules/.bin/yarn npm: 7.15.1 - ~/.npm-global/bin/npm Browsers: Chrome: 92.0.4515.107 Edge: 92.0.902.62 Firefox: 88.0 Safari: 14.1.2 npmPackages: @aws-amplify/ui-react: ^1.2.4 => 1.2.4 @material-ui/core: ^4.11.4 => 4.11.4 @material-ui/data-grid: ^4.0.0-alpha.33 => 4.0.0-alpha.33 @material-ui/icons: ^4.11.2 => 4.11.2 @material-ui/lab: ^4.0.0-alpha.58 => 4.0.0-alpha.58 @testing-library/jest-dom: ^5.11.4 => 5.14.1 @testing-library/react: ^11.1.0 => 11.2.7 @testing-library/user-event: ^12.1.10 => 12.8.3 aws-amplify: ^4.1.2 => 4.1.2 clsx: ^1.1.1 => 1.1.1 material-ui-dropzone: ^3.5.0 => 3.5.0 md5: ^2.3.0 => 2.3.0 moment: ^2.29.1 => 2.29.1 react: ^17.0.2 => 17.0.2 (17.0.1) react-dom: ^17.0.2 => 17.0.2 react-scripts: 4.0.3 => 4.0.3 web-vitals: ^1.0.1 => 1.1.2 npmGlobalPackages: @aws-amplify/cli: 5.2.1 @sap/cds-dk: 1.8.5 @sap/generator-fiori: 1.2.5 @ui5/cli: 2.10.2 create-react-app: 4.0.3 heroku: 7.47.7 jshint: 2.11.1 mbt: 1.1.0 nodemon: 2.0.7 npm: 7.15.1 typescript: 4.3.2 yo: 3.1.1 ```

Describe the bug

if the default retention period is on for the S3 bucket, storage.put throws 400 Bad request. Below is the response : InvalidRequestContent-MD5 HTTP header is required for Put Object requests with Object Lock parametersAJF7JQCNTAY5VV9GCzbzQMgX1QTytS49W8hcin2KpcwqxmyhL7mXc72SfHktzNeCVGtLwtW91rJ4JWBxlv44xUwclpg=

I tried passing the header in the put object but it doesn't consider it.

Expected behavior

Either it should add the content-MD5 in the header request by default or there should be an option to add it.

Reproduction steps

Create a new bucket with default retention period on. try to do put call with storage.put on the bucket. It will throw 400 bad request error

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

jamesaucode commented 2 years ago

Thanks for reporting the issue @rajnikumari022! I was able to reproduce the problem. I will look into allowing the ContentMD5 header to be passed into the call to fix this issue.

daniel-gato commented 2 years ago

As this been done? This is a blocker for us too.

kvramyasri7 commented 11 months ago

Now we can put an object by configuring isObjectLockEnabled in configure. Please do find the Ref Doc