@alpha-lambda/aws-drivers
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -54,10 +54,10 @@ 'use strict'; | ||
putObject(context, { bucket, data, key }, params) { | ||
putObject(context, { bucket, body, key }, params) { | ||
assert(context, 'missing context'); | ||
assert(bucket, 'missing bucket'); | ||
assert(data, 'missing data'); | ||
assert(body, 'missing body'); | ||
const putParams = { | ||
...params, | ||
Body: data, | ||
Body: body, | ||
Bucket: bucket, | ||
@@ -67,6 +67,4 @@ Key: key || uuid.v4() | ||
this._logger.log(context, { | ||
bucket: putParams.Bucket, | ||
key: putParams.Key | ||
}, 'storing object in S3'); | ||
const { Body, ...otherParams } = putParams; | ||
this._logger.log(context, otherParams, 'storing object in S3'); | ||
@@ -80,4 +78,3 @@ return this._client | ||
err, | ||
bucket: putParams.Bucket, | ||
key: putParams.Key | ||
...otherParams | ||
}, message); | ||
@@ -87,5 +84,42 @@ | ||
cause: err, | ||
details: putParams, | ||
message | ||
}); | ||
}); | ||
} | ||
upload(context, { bucket, body, key, options }, params) { | ||
assert(context, 'missing context'); | ||
assert(bucket, 'missing bucket'); | ||
assert(body, 'missing body'); | ||
const uploadParams = { | ||
...params, | ||
Body: body, | ||
Bucket: bucket, | ||
Key: key || uuid.v4() | ||
}; | ||
const { Body, ...otherParams } = uploadParams; | ||
this._logger.log(context, { | ||
params: otherParams, | ||
options | ||
}, 'uploading object to S3'); | ||
return this._client | ||
.upload(uploadParams, options) | ||
.promise() | ||
.catch((err) => { | ||
const message = 'failed to upload object to S3'; | ||
this._logger.log(context, { | ||
err, | ||
params: otherParams, | ||
options | ||
}, message); | ||
throw new AwsDriverError({ | ||
cause: err, | ||
details: { | ||
bucket: putParams.Bucket, | ||
key: putParams.Key | ||
params: uploadParams, | ||
options | ||
}, | ||
@@ -92,0 +126,0 @@ message |
{ | ||
"name": "@alpha-lambda/aws-drivers", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Wrappers for AWS SDK services that make life easier (sometimes)", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -53,9 +53,17 @@ # aws-drivers | ||
#### putObject(context, { bucket, data, [key] }, params) | ||
#### putObject(context, { bucket, body, [key] }, params) | ||
Adds an object to a bucket. | ||
- **bucket** - { String } - name of the bucket | ||
- **data** - { Buffer | Typed Array | Blob | String | ReadableStream } - object data | ||
- **body** - { Buffer | Typed Array | Blob | String | ReadableStream } - object data | ||
- **[key]** - { String } - object key [random UUID by default] | ||
- **[params]** - { Object } - any additional input parameters that [S3.putObject][s3-put-object-url] allows | ||
#### upload(context, { bucket, body, [key], [options] }, params) | ||
Uploads an arbitrarily sized buffer, blob, or stream, using intelligent concurrent handling of parts if the payload is large enough. | ||
- **bucket** - { String } - name of the bucket | ||
- **body** - { Buffer | Typed Array | Blob | String | ReadableStream } - object data | ||
- **[key]** - { String } - object key [random UUID by default] | ||
- **[options]** - { Object } - upload operation options such as [part and/or queue size][s3-upload-url] | ||
- **[params]** - { Object } - any additional input parameters that [S3.upload][s3-upload-url] allows | ||
### SQS | ||
@@ -131,1 +139,2 @@ | ||
[s3-put-object-url]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property | ||
[s3-upload-url]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143495
3668
139