@adtrackify/at-service-common 1.1.9 → 1.1.11
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/build.js +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -61297
- package/dist/index.js.map +4 -4
- package/package.json +3 -2
- package/src/clients/generic/s3-client.ts +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adtrackify/at-service-common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@adtrackify/at-tracking-event-types": "^1.1.2",
|
|
50
50
|
"@aws-sdk/client-dynamodb": "^3.278.0",
|
|
51
51
|
"@aws-sdk/client-eventbridge": "^3.278.0",
|
|
52
|
+
"@aws-sdk/client-s3": "^3.282.0",
|
|
52
53
|
"@aws-sdk/lib-dynamodb": "^3.279.0",
|
|
53
54
|
"@babel/cli": "^7.13.16",
|
|
54
55
|
"@babel/core": "^7.19.1",
|
|
@@ -102,4 +103,4 @@
|
|
|
102
103
|
"author": "",
|
|
103
104
|
"license": "ISC",
|
|
104
105
|
"homepage": "https://bitbucket.org/eacap/at-service-common#readme"
|
|
105
|
-
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { S3 } from '@aws-sdk/client-s3';
|
|
2
|
+
import * as log from 'lambda-log';
|
|
3
|
+
|
|
4
|
+
export default class S3Client {
|
|
5
|
+
s3: S3;
|
|
6
|
+
|
|
7
|
+
constructor(accessKeyId: string, secretAccessKey: string){
|
|
8
|
+
this.s3 = new S3({
|
|
9
|
+
credentials: {
|
|
10
|
+
accessKeyId,
|
|
11
|
+
secretAccessKey
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async uploadJson(path: string, bucket: string, jsonData: any){
|
|
17
|
+
try {
|
|
18
|
+
const res = await this.s3.putObject({
|
|
19
|
+
Bucket: bucket,
|
|
20
|
+
ContentType: 'application/json; charset=utf-8',
|
|
21
|
+
Body: JSON.stringify(jsonData),
|
|
22
|
+
Key: path
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return res;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
log.error('Error in s3 upload json', { error });
|
|
28
|
+
return error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|