forked from SaltwaterC/aws2js
-
Notifications
You must be signed in to change notification settings - Fork 0
s3.initUpload()
SaltwaterC edited this page Jan 30, 2012
·
1 revision
S3 Multipart Upload API helper for initiating a multipart upload
s3.initUpload(path, cannedAcl, headers, callback)
- 'path' - the S3 Path.
- 'cannedAcl' - the S3 Canned ACL.
- 'headers' - an object containing the HTTP headers you may want to pass to the POST request, such as the x-amz-* metadata headers.
- '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 an object indicating the initialization data for the multipart upload. It has the following keys: bucket, key, uploadId - which indicate the S3 bucket, the S3 Path, and the uploadId which is used by the Multipart Upload API to reference the in progress upload.
s3.setBucket('bar');
s3.initUpload('/foo', 'public-read', {'cache-control': 'public'}, function (err, res) {
if (err) {
console.error(err.message);
} else {
console.log(res);
/**
* Outputs something like:
* { bucket: 'bar',
* key: 'foo',
* uploadId: 'VXBsb2FkIElEIGZvciA2aWWpbmcncyBteS1tb3ZpZS5tMnRzIHVwbG9hZA' }
*/
}
});