Skip to content

Instantly share code, notes, and snippets.

@triloknagvenkar
Created December 11, 2018 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save triloknagvenkar/f631bf93a4b194a02d0acd19abc7d4b6 to your computer and use it in GitHub Desktop.
Save triloknagvenkar/f631bf93a4b194a02d0acd19abc7d4b6 to your computer and use it in GitHub Desktop.
/*
Completes a multipart upload by assembling previously uploaded parts.
*/
completeMultiUpload() {
var self = this;
var outputTag = [];
/*
here we are constructing the Etag data in the required format.
*/
self.etag.forEach((data, index) => {
const obj = {
ETag: data,
PartNumber: ++index
};
outputTag.push(obj);
});
var params = {
Bucket: self.bucketName, // required
Key: self.filename, // required
UploadId: self.uploadId, // required
MultipartUpload: {
Parts: outputTag
}
};
self.s3.completeMultipartUpload(params, function(err, data) {
if (err) {
console.log(err, err.stack)
} // an error occurred
else {
// initialize variable back to normal
self.etag = [], self.recordedChunks = [];
self.uploadId = "";
self.booleanStop = false;
self.disableAllButton();
self.removeLoader();
alert("we have successfully saved the questionaire..");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment