I am trying to create pre-signed url to upload object with SSE-Customer key encryption. I am able to generate pre-signed url with below code -
let aws = require('aws-sdk'); //require aws-sdk const s3 = new aws.S3(); //create a s3 GetObject & PutObject exports.handler = async(event) => { return await uploadFile('bucketname', 'TestFileWithEncryption.pdf'); }; const uploadFile = async(Bucket, ObjectPath) => { if (Bucket && Bucket != null && ObjectPath && ObjectPath != null) { console.log(`In uploadFile :: Creating a ${ObjectPath} folder in bucket ${Bucket} and returning its preSignedPostUrl`); return new Promise(async(resolve, reject) => { s3.getSignedUrl( 'putObject', { Bucket: Bucket, Key: ObjectPath, Expires: 3600, ContentType: 'multipart/form-data', SSECustomerAlgorithm: 'AES256', SSECustomerKey: 'xxxGcFP1HTBG0+Ty/1Nhuybz7vp+axBOaKA=', SSECustomerKeyMD5: 'xxxxxx/WJnw68mWssw==' }, function(err, data) { if (err) { reject(err); } else { resolve(data); } }); }); } else { console.log("uploadFile :: Bucket name and/or File path not provided"); return Promise.reject("Please provide Bucket Name and File Path"); } };
1.4m articles
1.4m replys
5 comments
57.0k users