Reputation: 71
Can any one please provide example of how to upload to s3 bucket using presigned url. I am able to generate pre singed url but using PUT verb I am not able to upload to S3, giving below error:
Access to XMLHttpRequest at 'https://s3-bulk-files-upload.s3.ap-south-1.amazonaws.com/File1.txt?X-Amz-Expires=599&x-amz-security-token=IQoJb3JpZ2luX2VjEDAaCXVzLWVh....' from origin 'http://localhost:2020' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Thanks, Raj4ms
Upvotes: 3
Views: 3635
Reputation: 71
Solved this issue by generating presinged url from aws-sdk javascript and upload the file using PUT operation, signed URL and added headers as below headers: new HttpHeaders({
'x-amz-server-side-encryption': 'aws:kms',
'x-amz-server-side-encryption-aws-kms-key-id': 'arn:aws:kms:us-east-1:...'
})
as S3 bucket is configured with KMS-encryption.
Upvotes: 1