presidium 4.1.5 → 4.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/S3Bucket.js +9 -6
  2. package/package.json +1 -1
package/S3Bucket.js CHANGED
@@ -212,8 +212,8 @@ class S3Bucket {
212
212
  */
213
213
  _awsRequest0(method, url, headers, body) {
214
214
  const amzDate = AmzDate()
215
- const payloadHash = headers.ChecksumSHA256
216
- ? Buffer.from(headers.ChecksumSHA256, 'base64').toString('hex')
215
+ const payloadHash = headers['X-Amz-Checksum-SHA256']
216
+ ? Buffer.from(headers['X-Amz-Checksum-SHA256'], 'base64').toString('hex')
217
217
  : crypto.createHash('sha256').update(body, 'utf8').digest('hex')
218
218
  const urlData = parseURL(url)
219
219
 
@@ -277,8 +277,8 @@ class S3Bucket {
277
277
  */
278
278
  _awsRequest1(method, url, headers, body) {
279
279
  const amzDate = AmzDate()
280
- const payloadHash = headers.ChecksumSHA256
281
- ? Buffer.from(headers.ChecksumSHA256, 'base64').toString('hex')
280
+ const payloadHash = headers['X-Amz-Checksum-SHA256']
281
+ ? Buffer.from(headers['X-Amz-Checksum-SHA256'], 'base64').toString('hex')
282
282
  : crypto.createHash('sha256').update(body, 'utf8').digest('hex')
283
283
  const urlData = parseURL(url)
284
284
 
@@ -287,7 +287,7 @@ class S3Bucket {
287
287
  'X-Amz-Content-SHA256': payloadHash,
288
288
  'X-Amz-Date': amzDate,
289
289
  'Date': new Date().toUTCString(),
290
- 'Content-Length': Buffer.byteLength(body, 'utf8'),
290
+ 'Content-Length': headers['Content-Length'] ?? Buffer.byteLength(body, 'utf8'),
291
291
  'User-Agent': userAgent,
292
292
  ...headers,
293
293
  }
@@ -799,6 +799,7 @@ class S3Bucket {
799
799
  * ObjectLockMode: 'GOVERNANCE'|'COMPLIANCE',
800
800
  * ObjectLockRetainUntilDate: Date|DateString|TimestampSeconds,
801
801
  * ObjectLockLegalHoldStatus: 'ON'|'OFF',
802
+ * ReadStream: boolean,
802
803
  * }
803
804
  * ) -> data Promise<{
804
805
  * Expiration: string,
@@ -858,6 +859,7 @@ class S3Bucket {
858
859
  * * `ObjectLockMode` - the object lock mode. For more information, see [Locking objects with Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html) from the _Amazon S3 User Guide_.
859
860
  * * `ObjectLockRetainUntilDate` - the date/time when the object's Object Lock expires. For more information, see [Locking objects with Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html) from the _Amazon S3 User Guide_.
860
861
  * * `ObjectLockLegalHoldStatus` - if `true`, a legal hold will be applied to the object. For more information, see [Locking objects with Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html) from the _Amazon S3 User Guide_.
862
+ * * `ReadStream` - `boolean` - whether to read the body as a readable stream into a buffer before uploading into the bucket. If `false`, the `ContentLength`, `ContentMD5`, `ChecksumSHA256` options are required along with this option. Defaults to `true`.
861
863
  *
862
864
  * Return:
863
865
  * * `data`
@@ -921,7 +923,8 @@ class S3Bucket {
921
923
  headers['Content-Length'] = options.ContentLength
922
924
  }
923
925
 
924
- if (body.readable) {
926
+ const ReadStream = options.ReadStream ?? true
927
+ if (ReadStream && body.readable) {
925
928
  body = await Readable.Buffer(body)
926
929
  }
927
930
  if (options.ContentMD5) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "4.1.5",
3
+ "version": "4.1.6",
4
4
  "description": "The Presidium library.",
5
5
  "author": "Richard Tong",
6
6
  "license": "CFOSS",