I'm using AWS to upload files to an S3 bucket. In the below code snippet, I'd like to update the value of uploadId but the the value returns undefined. I know its because the last line completes before the s3... block.
How do I kind of wait for the s3 block to complete before returning the updated value of uploadId?
let uploadId
let params = { Bucket: s3_bucket, Key: filename, ContentType: filetype }
s3.createMultipartUpload(params, (err, data) => {
uploadId = data.uploadId
console.log(uploadId)
console.log("uploadId err: ", err)
})
return uploadId