@goldstack/utils-s3 0.2.17 → 0.3.0
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/src/utilsS3.d.ts +10 -10
- package/dist/src/utilsS3.js +41 -41
- package/package.json +5 -5
package/dist/src/utilsS3.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import S3 from 'aws-sdk/clients/s3';
|
|
2
|
-
/**
|
|
3
|
-
* Downloads a file from S3 to a local file.
|
|
4
|
-
*/
|
|
5
|
-
export declare const download: (params: {
|
|
6
|
-
key: string;
|
|
7
|
-
filePath: string;
|
|
8
|
-
s3: S3;
|
|
9
|
-
bucketName: string;
|
|
10
|
-
}) => Promise<boolean>;
|
|
1
|
+
import S3 from 'aws-sdk/clients/s3';
|
|
2
|
+
/**
|
|
3
|
+
* Downloads a file from S3 to a local file.
|
|
4
|
+
*/
|
|
5
|
+
export declare const download: (params: {
|
|
6
|
+
key: string;
|
|
7
|
+
filePath: string;
|
|
8
|
+
s3: S3;
|
|
9
|
+
bucketName: string;
|
|
10
|
+
}) => Promise<boolean>;
|
|
11
11
|
//# sourceMappingURL=utilsS3.d.ts.map
|
package/dist/src/utilsS3.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.download = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
/**
|
|
9
|
-
* Downloads a file from S3 to a local file.
|
|
10
|
-
*/
|
|
11
|
-
const download = async (params) => {
|
|
12
|
-
const filePath = params.filePath;
|
|
13
|
-
return new Promise((resolve, reject) => {
|
|
14
|
-
const file = fs_1.default.createWriteStream(filePath);
|
|
15
|
-
try {
|
|
16
|
-
params.s3
|
|
17
|
-
.getObject({
|
|
18
|
-
Bucket: params.bucketName,
|
|
19
|
-
Key: params.key,
|
|
20
|
-
})
|
|
21
|
-
.createReadStream()
|
|
22
|
-
.pipe(file);
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
const awsError = e;
|
|
26
|
-
if (awsError.code === 'NoSuchKey') {
|
|
27
|
-
resolve(false);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
reject(e);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
file.on('finish', () => {
|
|
34
|
-
resolve(true);
|
|
35
|
-
});
|
|
36
|
-
file.on('error', (e) => {
|
|
37
|
-
reject(e);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
exports.download = download;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.download = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
/**
|
|
9
|
+
* Downloads a file from S3 to a local file.
|
|
10
|
+
*/
|
|
11
|
+
const download = async (params) => {
|
|
12
|
+
const filePath = params.filePath;
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const file = fs_1.default.createWriteStream(filePath);
|
|
15
|
+
try {
|
|
16
|
+
params.s3
|
|
17
|
+
.getObject({
|
|
18
|
+
Bucket: params.bucketName,
|
|
19
|
+
Key: params.key,
|
|
20
|
+
})
|
|
21
|
+
.createReadStream()
|
|
22
|
+
.pipe(file);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
const awsError = e;
|
|
26
|
+
if (awsError.code === 'NoSuchKey') {
|
|
27
|
+
resolve(false);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
reject(e);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
file.on('finish', () => {
|
|
34
|
+
resolve(true);
|
|
35
|
+
});
|
|
36
|
+
file.on('error', (e) => {
|
|
37
|
+
reject(e);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
exports.download = download;
|
|
42
42
|
//# sourceMappingURL=utilsS3.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goldstack/utils-s3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Utilities for downloading files from S3",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"goldstack",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"aws-sdk": "2.1055.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@goldstack/utils-git": "0.
|
|
43
|
-
"@types/jest": "^
|
|
44
|
-
"@types/node": "^
|
|
42
|
+
"@goldstack/utils-git": "0.2.0",
|
|
43
|
+
"@types/jest": "^28.1.8",
|
|
44
|
+
"@types/node": "^18.7.13",
|
|
45
45
|
"jest": "^28.1.0",
|
|
46
46
|
"rimraf": "^3.0.2",
|
|
47
47
|
"ts-jest": "^28.0.2",
|
|
48
|
-
"typescript": "^4.
|
|
48
|
+
"typescript": "^4.7.4"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"main": "dist/src/utilsS3.js"
|