@qrvey/object-storage 0.0.11-beta.3 → 1.0.1-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.
@@ -107,7 +107,7 @@ interface IObjectStorage {
107
107
  upload(key: string, body: FileContent, metadata?: {
108
108
  [key: string]: string;
109
109
  }): Promise<UploadResponse>;
110
- createUploadWriteStream(key: string): CreateUploadWriteStreamResponse;
110
+ createUploadWriteStream(key: string, streamPassThrough?: stream.PassThrough): CreateUploadWriteStreamResponse;
111
111
  delete(key: string): Promise<boolean>;
112
112
  getHeadBucket(): Promise<HeadBucketResponse>;
113
113
  generateUploadIdMultipart(key: string): Promise<string>;
@@ -195,7 +195,7 @@ declare class ObjectStorageService {
195
195
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
196
196
  * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
197
197
  */
198
- static createUploadWriteStream(key: string, bucketName?: string): Promise<CreateUploadWriteStreamResponse>;
198
+ static createUploadWriteStream(key: string, bucketName?: string, streamPassThrough?: stream.PassThrough): Promise<CreateUploadWriteStreamResponse>;
199
199
  /**
200
200
  * Deletes an object or multiple objects from the object storage service.
201
201
  *
@@ -145,20 +145,21 @@ var BlobStorageService = class {
145
145
  * @param {string} blobName - The name of the blob to upload.
146
146
  * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded blob, the writable stream, and a promise that resolves when the upload is complete.
147
147
  */
148
- createUploadWriteStream(blobName) {
149
- const streamPassThrough = new stream.PassThrough();
148
+ createUploadWriteStream(blobName, streamPassThrough) {
149
+ const streamPass = new stream.PassThrough();
150
+ const streamResponse = streamPassThrough != null ? streamPassThrough : streamPass;
150
151
  const containerClient = this.blobServiceClient.getContainerClient(
151
152
  this.containerName
152
153
  );
153
154
  const blockBlobClient = containerClient.getBlockBlobClient(blobName);
154
- const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
155
+ const uploadPromise = blockBlobClient.uploadStream(streamResponse, void 0, void 0, {
155
156
  onProgress: (ev) => console.log(ev)
156
157
  }).then(() => {
157
158
  return { Bucket: this.containerName, Key: blobName };
158
159
  });
159
160
  return {
160
161
  key: blobName,
161
- stream: streamPassThrough,
162
+ stream: streamResponse,
162
163
  promise: uploadPromise
163
164
  };
164
165
  }
@@ -1194,12 +1195,13 @@ var S3StorageService = class {
1194
1195
  * @param {string} key - The key of the object to upload.
1195
1196
  * @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.
1196
1197
  */
1197
- createUploadWriteStream(key) {
1198
- const streamPassThrough = new stream.PassThrough();
1198
+ createUploadWriteStream(key, streamPassThrough) {
1199
+ const streamPass = new stream.PassThrough();
1200
+ const streamResponse = streamPassThrough != null ? streamPassThrough : streamPass;
1199
1201
  const params = {
1200
1202
  Bucket: this.bucketName,
1201
1203
  Key: key,
1202
- Body: streamPassThrough
1204
+ Body: streamResponse
1203
1205
  };
1204
1206
  const upload = new Upload({
1205
1207
  client: this.s3Client,
@@ -1209,7 +1211,7 @@ var S3StorageService = class {
1209
1211
  });
1210
1212
  return {
1211
1213
  key,
1212
- stream: streamPassThrough,
1214
+ stream: streamResponse,
1213
1215
  promise: upload.done()
1214
1216
  };
1215
1217
  }
@@ -1487,10 +1489,12 @@ var ObjectStorageService = class _ObjectStorageService {
1487
1489
  * @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
1488
1490
  * @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
1489
1491
  */
1490
- static async createUploadWriteStream(key, bucketName) {
1492
+ static async createUploadWriteStream(key, bucketName, streamPassThrough) {
1491
1493
  return _ObjectStorageService.getObjectStorageServiceInstance(
1492
1494
  bucketName
1493
- ).then((instance) => instance.createUploadWriteStream(key));
1495
+ ).then(
1496
+ (instance) => instance.createUploadWriteStream(key, streamPassThrough)
1497
+ );
1494
1498
  }
1495
1499
  /**
1496
1500
  * Deletes an object or multiple objects from the object storage service.