javascript - AWS S3 SDK: Abort a putObject upload in progress -
i'm uploading files s3 bucket using putobject
params = { key: videokey, contenttype: file.type, body: file, acl: "public-read" }; req = s3.putobject(params).on('httpuploadprogress', function(evt) { // calculate percentage complete var percentcomplete = math.round(evt.loaded / evt.total * 100); $cancelbtn.on("click", function(evt) { req.abort.bind(req); // doesn't work; returns error }); }).send(function(err, data) { // code handle happens after upload completes }); i've read in multiple locations use req.abort() or req.abort.bind(req), seems returning following error:
'req.abort not function. (in 're.abort()', 'req.abort' undefined)' it's true 'req' doesn't seem have abort() function in object, i'm wondering if tied older version of aws sdk. if so, what's proper way deal this? i've read documentation on amazon's website method called abortmultipartupload method requires uploadid , can't figure how retrieve putobject function. how retrieve response uploadid before 'send' callback?
thanks help!
-michael
the s3 putobject api not multi-part request. abortmultipartupload or completemultipartupload required or can used when initiate multi-part request using createmultipartupload. response of createmultipartupload api returns uploadid value.
createmultipartupload(params = {}, callback) ⇒ aws.request initiates multipart upload , returns upload id.note: after initiate multipart upload , upload 1 or more parts, must either complete or abort multipart upload in order stop getting charged storage of uploaded parts.
multi-part upload steps:-
1) multi-part upload initiation - api createmultipartupload
2) parts upload - api upload or uploadpart
3) multi-part upload completion (or abort) - api abortmultipartupload or completemultipartupload
Comments
Post a Comment