@quatrain/storage-s3 1.1.10 → 1.1.12
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.d.ts +9 -1
- package/lib/S3StorageAdapter.js +22 -1
- package/package.json +8 -4
|
@@ -11,13 +11,21 @@ export declare class S3StorageAdapter extends AbstractStorageAdapter {
|
|
|
11
11
|
streamToBuffer(stream: Stream): Promise<Buffer>;
|
|
12
12
|
create(file: FileType, stream: Readable): Promise<FileType>;
|
|
13
13
|
copy(file: FileType, destFile: FileType): Promise<void>;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Move file to given destination
|
|
16
|
+
* There is no native command in AWS SDK for this, we need to copy then delete source media
|
|
17
|
+
* @param file
|
|
18
|
+
* @param destFile
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
move(file: FileType, destFile: FileType): Promise<FileType>;
|
|
15
22
|
getUrl(file: FileType, expiresIn?: number): Promise<{
|
|
16
23
|
url: string;
|
|
17
24
|
expiresIn: number;
|
|
18
25
|
}>;
|
|
19
26
|
delete(file: FileType): Promise<boolean>;
|
|
20
27
|
getReadable(file: FileType): Promise<Readable>;
|
|
28
|
+
getMetaData(file: FileType): Promise<FileType>;
|
|
21
29
|
stream(file: FileType, res: any): Promise<any>;
|
|
22
30
|
download(file: FileType, meta: DownloadFileMetaType): Promise<string>;
|
|
23
31
|
getUploadUrl(file: FileType, expiresIn?: number): Promise<FileResponseLinkType>;
|
package/lib/S3StorageAdapter.js
CHANGED
|
@@ -73,15 +73,25 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Move file to given destination
|
|
78
|
+
* There is no native command in AWS SDK for this, we need to copy then delete source media
|
|
79
|
+
* @param file
|
|
80
|
+
* @param destFile
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
76
83
|
move(file, destFile) {
|
|
77
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
85
|
try {
|
|
86
|
+
storage_1.Storage.debug(`Moving file from ${file.ref} to ${destFile.ref}`);
|
|
79
87
|
yield this.copy(file, destFile);
|
|
80
88
|
yield this.delete(file);
|
|
81
89
|
}
|
|
82
90
|
catch (err) {
|
|
91
|
+
storage_1.Storage.error(`Failed to move file from ${file.ref} to ${destFile.ref}: ${err.message}`);
|
|
83
92
|
console.log(err);
|
|
84
93
|
}
|
|
94
|
+
return destFile;
|
|
85
95
|
});
|
|
86
96
|
}
|
|
87
97
|
getUrl(file, expiresIn = 3600) {
|
|
@@ -98,7 +108,7 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
98
108
|
delete(file) {
|
|
99
109
|
var _a;
|
|
100
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
storage_1.Storage.
|
|
111
|
+
storage_1.Storage.debug(`Deleting file ${file.ref}`);
|
|
102
112
|
const command = new client_s3_1.DeleteObjectCommand({
|
|
103
113
|
Bucket: file.bucket,
|
|
104
114
|
Key: file.ref,
|
|
@@ -125,6 +135,17 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
|
|
|
125
135
|
return readable;
|
|
126
136
|
});
|
|
127
137
|
}
|
|
138
|
+
getMetaData(file) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
const command = new client_s3_1.HeadObjectCommand({
|
|
141
|
+
Bucket: file.bucket,
|
|
142
|
+
Key: file.ref,
|
|
143
|
+
});
|
|
144
|
+
const item = yield this._client.send(command);
|
|
145
|
+
const meta = Object.assign(Object.assign({}, file), { contentType: item.ContentType, size: item.ContentLength, lastModified: item.LastModified });
|
|
146
|
+
return meta;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
128
149
|
stream(file, res) {
|
|
129
150
|
var _a;
|
|
130
151
|
return __awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/storage-s3",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "Storage adapter for S3 compatible services",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -24,14 +24,18 @@
|
|
|
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.12",
|
|
28
28
|
"fs-extra": "^11.2.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"test": "
|
|
31
|
+
"test-ci": "jest --runInBand",
|
|
32
32
|
"build": "tsc",
|
|
33
33
|
"wbuild": "tsc --watch",
|
|
34
34
|
"bump-to": "yarn version",
|
|
35
|
-
"
|
|
35
|
+
"hash": "node ../../bin/hashFolder.js",
|
|
36
|
+
"hash:persist": "yarn hash > .hash_latest.txt",
|
|
37
|
+
"hash:compare": "yarn hash > .hash_newest.txt && cmp -s .hash_latest.txt .hash_newest.txt",
|
|
38
|
+
"publish": "yarn hash:compare || yarn publish:process",
|
|
39
|
+
"publish:process": "yarn version patch && yarn build && yarn npm publish --access public && yarn hash:persist"
|
|
36
40
|
}
|
|
37
41
|
}
|