SaltwaterC edited this page Jan 30, 2012 · 2 revisions


S3 Multipart Upload API helper for completing a multipart upload


s3.completeUpload(path, uploadId, uploadParts, callback)
  • 'path' - the S3 Path.
  • 'uploadId' - the uploadId from s3.initUpload().
  • 'uploadParts' - an object / array containing the upload parts references.
  • 'callback' - the callback that is executed when the processing finishes. It has a couple of arguments: error and result.
  • If there's an error, the callback receives the error argument as Error instance.
  • If the error argument is null, then the response argument contains the parsed XML document as JavaScript object. It includes the following keys: Location, Bucket, Key, ETag. The Location is the full URL to the uploaded object. The Key is analogue to the path argument of this method.

The uploadParts object must have the following structure:

'1': '"etag-for-part-1"',
'2': '"etag-for-part-2"',
'n': '"etag-for-part-n"'
// or
 1: '"etag-for-part-1"',
 2: '"etag-for-part-2"',
 n: '"etag-for-part-n"'

The API expects the keys to be sorted. V8 is kind enough to sort them for the objects, therefore you don't have to take extra measures for this.