@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 +15 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +15 -16
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +29 -28
package/dist/esm/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import stream, { Readable } from 'stream';
|
|
2
2
|
import { BlobServiceClient, BlobSASPermissions } from '@azure/storage-blob';
|
|
3
3
|
import { S3Client, S3, ListObjectsV2Command, HeadObjectCommand, GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadBucketCommand, UploadPartCommand } from '@aws-sdk/client-s3';
|
|
4
|
+
import { defaultProvider } from '@aws-sdk/credential-provider-node';
|
|
4
5
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
5
6
|
import { Upload } from '@aws-sdk/lib-storage';
|
|
6
7
|
import { Agent, request as request$1 } from 'http';
|
|
@@ -145,21 +146,20 @@ var BlobStorageService = class {
|
|
|
145
146
|
* @param {string} blobName - The name of the blob to upload.
|
|
146
147
|
* @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
148
|
*/
|
|
148
|
-
createUploadWriteStream(blobName
|
|
149
|
-
const
|
|
150
|
-
const streamResponse = streamPassThrough != null ? streamPassThrough : streamPass;
|
|
149
|
+
createUploadWriteStream(blobName) {
|
|
150
|
+
const streamPassThrough = new stream.PassThrough();
|
|
151
151
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
152
152
|
this.containerName
|
|
153
153
|
);
|
|
154
154
|
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
155
|
-
const uploadPromise = blockBlobClient.uploadStream(
|
|
155
|
+
const uploadPromise = blockBlobClient.uploadStream(streamPassThrough, void 0, void 0, {
|
|
156
156
|
onProgress: (ev) => console.log(ev)
|
|
157
157
|
}).then(() => {
|
|
158
158
|
return { Bucket: this.containerName, Key: blobName };
|
|
159
159
|
});
|
|
160
160
|
return {
|
|
161
161
|
key: blobName,
|
|
162
|
-
stream:
|
|
162
|
+
stream: streamPassThrough,
|
|
163
163
|
promise: uploadPromise
|
|
164
164
|
};
|
|
165
165
|
}
|
|
@@ -1008,11 +1008,13 @@ var S3StorageService = class {
|
|
|
1008
1008
|
});
|
|
1009
1009
|
this.s3Client = new S3Client({
|
|
1010
1010
|
region: process.env.AWS_DEFAULT_REGION,
|
|
1011
|
-
requestHandler: this.httpHandler
|
|
1011
|
+
requestHandler: this.httpHandler,
|
|
1012
|
+
credentials: defaultProvider()
|
|
1012
1013
|
});
|
|
1013
1014
|
this.s3 = new S3({
|
|
1014
1015
|
region: process.env.AWS_DEFAULT_REGION,
|
|
1015
|
-
requestHandler: this.httpHandler
|
|
1016
|
+
requestHandler: this.httpHandler,
|
|
1017
|
+
credentials: defaultProvider()
|
|
1016
1018
|
});
|
|
1017
1019
|
var _a, _b, _c, _d;
|
|
1018
1020
|
this.bucketName = bucketName;
|
|
@@ -1195,13 +1197,12 @@ var S3StorageService = class {
|
|
|
1195
1197
|
* @param {string} key - The key of the object to upload.
|
|
1196
1198
|
* @return {CreateUploadWriteStreamResponse} An object containing the key of the uploaded object, the writable stream, and a promise that resolves when the upload is complete.
|
|
1197
1199
|
*/
|
|
1198
|
-
createUploadWriteStream(key
|
|
1199
|
-
const
|
|
1200
|
-
const streamResponse = streamPassThrough != null ? streamPassThrough : streamPass;
|
|
1200
|
+
createUploadWriteStream(key) {
|
|
1201
|
+
const streamPassThrough = new stream.PassThrough();
|
|
1201
1202
|
const params = {
|
|
1202
1203
|
Bucket: this.bucketName,
|
|
1203
1204
|
Key: key,
|
|
1204
|
-
Body:
|
|
1205
|
+
Body: streamPassThrough
|
|
1205
1206
|
};
|
|
1206
1207
|
const upload = new Upload({
|
|
1207
1208
|
client: this.s3Client,
|
|
@@ -1211,7 +1212,7 @@ var S3StorageService = class {
|
|
|
1211
1212
|
});
|
|
1212
1213
|
return {
|
|
1213
1214
|
key,
|
|
1214
|
-
stream:
|
|
1215
|
+
stream: streamPassThrough,
|
|
1215
1216
|
promise: upload.done()
|
|
1216
1217
|
};
|
|
1217
1218
|
}
|
|
@@ -1489,12 +1490,10 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1489
1490
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1490
1491
|
* @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
|
|
1491
1492
|
*/
|
|
1492
|
-
static async createUploadWriteStream(key, bucketName
|
|
1493
|
+
static async createUploadWriteStream(key, bucketName) {
|
|
1493
1494
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1494
1495
|
bucketName
|
|
1495
|
-
).then(
|
|
1496
|
-
(instance) => instance.createUploadWriteStream(key, streamPassThrough)
|
|
1497
|
-
);
|
|
1496
|
+
).then((instance) => instance.createUploadWriteStream(key));
|
|
1498
1497
|
}
|
|
1499
1498
|
/**
|
|
1500
1499
|
* Deletes an object or multiple objects from the object storage service.
|