@qrvey/object-storage 1.0.1-beta → 1.0.2-beta

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/dist/cjs/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  var stream = require('stream');
4
4
  var storageBlob = require('@azure/storage-blob');
5
5
  var clientS3 = require('@aws-sdk/client-s3');
6
+ var credentialProviderNode = require('@aws-sdk/credential-provider-node');
6
7
  var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
7
8
  var libStorage = require('@aws-sdk/lib-storage');
8
9
  var http = require('http');
@@ -151,21 +152,20 @@ var BlobStorageService = class {
151
152
  * @param {string} blobName - The name of the blob to upload.
152
153
  * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded blob, the writable stream, and a promise that resolves when the upload is complete.
153
154
  */
154
- createUploadWriteStream(blobName, streamPassThrough) {
155
- const streamPass = new stream__default.default.PassThrough();
156
- const streamResponse = streamPassThrough != null ? streamPassThrough : streamPass;
155
+ createUploadWriteStream(blobName) {
156
+ const streamPassThrough = new stream__default.default.PassThrough();
157
157
  const containerClient = this.blobServiceClient.getContainerClient(
158
158
  this.containerName
159
159
  );
160
160
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
161
- const uploadPromise = blockBlobClient.uploadStream(streamResponse, void 0, void 0, {
161
+ const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
162
162
  onProgress: (ev) => console.log(ev)
163
163
  }).then(() => {
164
164
  return { Bucket: this.containerName, Key: blobName };
165
165
  });
166
166
  return {
167
167
  key: blobName,
168
- stream: streamResponse,
168
+ stream: streamPassThrough,
169
169
  promise: uploadPromise
170
170
  };
171
171
  }
@@ -1014,11 +1014,13 @@ var S3StorageService = class {
1014
1014
  });
1015
1015
  this.s3Client = new clientS3.S3Client({
1016
1016
  region: process.env.AWS_DEFAULT_REGION,
1017
- requestHandler: this.httpHandler
1017
+ requestHandler: this.httpHandler,
1018
+ credentials: credentialProviderNode.defaultProvider()
1018
1019
  });
1019
1020
  this.s3 = new clientS3.S3({
1020
1021
  region: process.env.AWS_DEFAULT_REGION,
1021
- requestHandler: this.httpHandler
1022
+ requestHandler: this.httpHandler,
1023
+ credentials: credentialProviderNode.defaultProvider()
1022
1024
  });
1023
1025
  var _a, _b, _c, _d;
1024
1026
  this.bucketName = bucketName;
@@ -1201,13 +1203,12 @@ var S3StorageService = class {
1201
1203
  * @param {string} key - The key of the object to upload.
1202
1204
  * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.
1203
1205
  */
1204
- createUploadWriteStream(key, streamPassThrough) {
1205
- const streamPass = new stream__default.default.PassThrough();
1206
- const streamResponse = streamPassThrough != null ? streamPassThrough : streamPass;
1206
+ createUploadWriteStream(key) {
1207
+ const streamPassThrough = new stream__default.default.PassThrough();
1207
1208
  const params = {
1208
1209
  Bucket: this.bucketName,
1209
1210
  Key: key,
1210
- Body: streamResponse
1211
+ Body: streamPassThrough
1211
1212
  };
1212
1213
  const upload = new libStorage.Upload({
1213
1214
  client: this.s3Client,
@@ -1217,7 +1218,7 @@ var S3StorageService = class {
1217
1218
  });
1218
1219
  return {
1219
1220
  key,
1220
- stream: streamResponse,
1221
+ stream: streamPassThrough,
1221
1222
  promise: upload.done()
1222
1223
  };
1223
1224
  }
@@ -1495,12 +1496,10 @@ var ObjectStorageService = class _ObjectStorageService {
1495
1496
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1496
1497
  * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
1497
1498
  */
1498
- static async createUploadWriteStream(key, bucketName, streamPassThrough) {
1499
+ static async createUploadWriteStream(key, bucketName) {
1499
1500
  return _ObjectStorageService.getObjectStorageServiceInstance(
1500
1501
  bucketName
1501
- ).then(
1502
- (instance) => instance.createUploadWriteStream(key, streamPassThrough)
1503
- );
1502
+ ).then((instance) => instance.createUploadWriteStream(key));
1504
1503
  }
1505
1504
  /**
1506
1505
  * Deletes an object or multiple objects from the object storage service.