@quatrain/storage-s3 1.1.7 → 1.1.10
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/lib/S3StorageAdapter.js +11 -10
- package/package.json +2 -2
package/lib/S3StorageAdapter.js
CHANGED
|
@@ -28,7 +28,7 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
this._client = new client_s3_1.S3Client(config);
|
|
31
|
-
storage_1.Storage.
|
|
31
|
+
storage_1.Storage.info(`AWS Storage Adapter initialized in ${this._params.config.region}`);
|
|
32
32
|
}
|
|
33
33
|
getDriver() {
|
|
34
34
|
return this._client;
|
|
@@ -51,7 +51,7 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
51
51
|
Body: yield this.streamToBuffer(stream),
|
|
52
52
|
ContentType: file.contentType,
|
|
53
53
|
};
|
|
54
|
-
storage_1.Storage.
|
|
54
|
+
storage_1.Storage.debug(`Uploading ${file.ref} to ${file.bucket}`);
|
|
55
55
|
const command = new client_s3_1.PutObjectCommand(input);
|
|
56
56
|
yield this._client.send(command);
|
|
57
57
|
return file;
|
|
@@ -59,7 +59,7 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
59
59
|
}
|
|
60
60
|
copy(file, destFile) {
|
|
61
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
storage_1.Storage.
|
|
62
|
+
storage_1.Storage.debug(`Copying file ${file.ref} to ${destFile.ref}`);
|
|
63
63
|
const command = new client_s3_1.CopyObjectCommand({
|
|
64
64
|
CopySource: encodeURI(`${file.bucket}/${file.ref}`),
|
|
65
65
|
Bucket: file.bucket,
|
|
@@ -90,6 +90,7 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
90
90
|
Bucket: file.bucket,
|
|
91
91
|
Key: encodeURI(file.ref),
|
|
92
92
|
});
|
|
93
|
+
storage_1.Storage.debug(`Creating public url for ${file.ref}`);
|
|
93
94
|
const url = yield (0, s3_request_presigner_1.getSignedUrl)(this._client, command, { expiresIn });
|
|
94
95
|
return { url, expiresIn };
|
|
95
96
|
});
|
|
@@ -103,14 +104,14 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
103
104
|
Key: file.ref,
|
|
104
105
|
});
|
|
105
106
|
yield ((_a = this._client) === null || _a === void 0 ? void 0 : _a.send(command));
|
|
106
|
-
storage_1.Storage.
|
|
107
|
+
storage_1.Storage.info(`Object ${file.ref} successfully deleted`);
|
|
107
108
|
return true;
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
111
|
getReadable(file) {
|
|
111
112
|
var _a, _b;
|
|
112
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
storage_1.Storage.
|
|
114
|
+
storage_1.Storage.debug(`GET Readable for ${file.ref}`);
|
|
114
115
|
const command = new client_s3_1.GetObjectCommand({
|
|
115
116
|
Bucket: file.bucket || this._params.config.bucket,
|
|
116
117
|
Key: file.ref,
|
|
@@ -149,15 +150,15 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
149
150
|
}
|
|
150
151
|
getUploadUrl(file, expiresIn = 3600) {
|
|
151
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
const
|
|
153
|
+
const command = new client_s3_1.PutObjectCommand({
|
|
153
154
|
Bucket: file.bucket || this._params.config.bucket,
|
|
154
155
|
Key: file.ref,
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
ContentType: file.contentType,
|
|
157
|
+
});
|
|
157
158
|
const url = yield (0, s3_request_presigner_1.getSignedUrl)(this._client, command, { expiresIn });
|
|
158
159
|
return {
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
url,
|
|
161
|
+
method: 'PUT',
|
|
161
162
|
accept: file.contentType || 'application/octet-stream',
|
|
162
163
|
expiresIn,
|
|
163
164
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/storage-s3",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "Storage adapter for S3 compatible services",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@aws-sdk/client-s3": "^3.337.0",
|
|
26
26
|
"@aws-sdk/s3-request-presigner": "^3.342.0",
|
|
27
|
-
"@quatrain/storage": "^1.1.
|
|
27
|
+
"@quatrain/storage": "^1.1.10",
|
|
28
28
|
"fs-extra": "^11.2.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|