eip-cloud-services 1.1.6 → 1.1.7
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.
- package/package.json +1 -1
- package/src/s3.js +15 -6
package/package.json
CHANGED
package/src/s3.js
CHANGED
|
@@ -51,6 +51,9 @@ const crypto = require ( 'crypto' );
|
|
|
51
51
|
const { cwd } = require ( 'process' );
|
|
52
52
|
const { log } = config?.s3?.logsFunction ? require ( `${ cwd ()}/${config?.s3?.logsFunction}` ) : console;
|
|
53
53
|
const S3 = new S3Client ( { region: 'eu-west-1' } );
|
|
54
|
+
const { pipeline, Writable } = require ( 'stream' );
|
|
55
|
+
const util = require ( 'util' );
|
|
56
|
+
const pipelineAsync = util.promisify ( pipeline );
|
|
54
57
|
|
|
55
58
|
/**
|
|
56
59
|
* Check if an object exists in S3.
|
|
@@ -389,10 +392,16 @@ exports.listObjects = async ( prefix, bucket = config?.s3?.Bucket, continuationT
|
|
|
389
392
|
|
|
390
393
|
exports.getClient = S3;
|
|
391
394
|
|
|
392
|
-
const streamToBuffer = ( stream ) =>
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
395
|
+
const streamToBuffer = async ( stream ) => {
|
|
396
|
+
const chunks = [];
|
|
397
|
+
const collectorStream = new Writable ( {
|
|
398
|
+
write ( chunk, encoding, callback ) {
|
|
399
|
+
chunks.push ( chunk );
|
|
400
|
+
callback ();
|
|
401
|
+
}
|
|
398
402
|
} );
|
|
403
|
+
|
|
404
|
+
await pipelineAsync ( stream, collectorStream );
|
|
405
|
+
|
|
406
|
+
return Buffer.concat ( chunks );
|
|
407
|
+
};
|