I had this part of code to send a file to S3 using Amplify
const file = e.target.files[0];
try {
console.log(Storage.vault)
await Storage.put(file.name, file);
} catch (error) {
console.log('Error uploading file: ', error);
}
But always return this error:
<Error>
<Code>AuthorizationHeaderMalformed</Code>
<Message>The authorization header is malformed; the authorization header requires three components: Credential, SignedHeaders, and Signature.</Message>
<RequestId>YP2HEHPE20T13HNJ</RequestId>
<HostId>T5mH0m+CHZ6n/JuShi7FdUBYZt3BEz4QiEHMmckL0v5VrB7DqupGbmadxDgZnitWFI0IUYVmBig=</HostId></Error>
I using Cognito to make login to my system, and use this code to setting de configuration of Amplify
Auth: {
identityPoolId: process.env.REACT_APP_IDENTITY_POOL_ID,
region: process.env.REACT_APP_REGION,
userPoolId: process.env.REACT_APP_USER_POOL_ID,
userPoolWebClientId: process.env.REACT_APP_CLIENT_ID,
},
Storage: {
AWSS3: {
region: process.env.REACT_APP_REGION,
bucket: process.env.REACT_APP_BUCKET,
}
}
If i use the AWS SDK getting connection info on Amplify, i can make the upload on S3, but only with Amplify don't.
To configure my Bucket and Identity pool i used the amplify docs.