-
Notifications
You must be signed in to change notification settings - Fork 32
s3.putFiles()
SaltwaterC edited this page Dec 26, 2012
·
1 revision
S3 helper that wraps s3.putFile() for uploading multiple objects at once.
s3.putFiles(files, cannedAcl, headers, callback)
- 'files' - an Array of Objects containing the list of the files to upload. Has the following structure:
[{path: '/s3/path1', file: '/path/to/file1'}, {path: '/s3/path2', file: '/path/to/file2'}]
where the path key indicates the S3 Path and the file key indicates the filesystem path of the file to upload. It may be a relative path. Is resolved to an absolute path by path.resolve(). - 'cannedAcl' - the S3 Canned ACL.
- 'headers' - an object containing the HTTP headers you may want to pass to the PUT request, such as the x-amz-* metadata headers.
- 'callback' - the callback that is executed when all the uploads are completed. Accepts a couple of arguments: errors and results. Due to the batch mode of this operation in an async framework where the completion order is arbitrary, both errors and results are arrays keeping the same index as the files array in order to keep track of the state of each operation. They collect the arguments passed to the s3.putFile() completion callback.
You may add the Content-Type header in order to indicate the MIME type of the resource. If this header is blank, then the library uses mime-magic to compute the MIME type. Due to the batch mode of this operation, you may manually pass the Content-Type header just for a bunch of objects of the same type.
The Content-Length and Content-MD5 headers are automatically computed and you may not override them.