-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paths3-client.js
More file actions
64 lines (51 loc) · 1.34 KB
/
s3-client.js
File metadata and controls
64 lines (51 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const AWS = require('aws-sdk')
const s3 = new AWS.S3()
const BUCKET_NAME = 'bpro'
const uploadScoreFile = (jsonString) => {
return new Promise((resolve, reject) => {
// Read content from the file
// Setting up S3 upload parameters
const params = {
Bucket: BUCKET_NAME,
Key: 'score.json', // File name you want to save as in S3
Body: jsonString,
ACL: 'public-read'
};
console.log(params)
// Uploading files to the bucket
s3.upload(params, function(err, data) {
if (err) {
reject(err)
return
}
console.log(`File uploaded successfully.`);
resolve(data)
});
})
}
const uploadJsonFile = (jsonString, fileName) => {
return new Promise((resolve, reject) => {
// Read content from the file
// Setting up S3 upload parameters
const params = {
Bucket: BUCKET_NAME,
Key: fileName, // File name you want to save as in S3
Body: jsonString,
ACL: 'public-read'
};
console.log(params)
// Uploading files to the bucket
s3.upload(params, function(err, data) {
if (err) {
reject(err)
return
}
console.log(`File uploaded successfully.`);
resolve(data)
});
})
}
module.exports = {
uploadScoreFile,
uploadJsonFile
}