forked from matteobrusa/Tumbless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3.js
49 lines (40 loc) · 750 Bytes
/
s3.js
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
function setS3Credentials(data) {
AWS.config.update(data);
AWS.config.region = s3region;
}
function testS3() {
var bucket = new AWS.S3({
params : {
Bucket : s3bucket
}
});
var params = {
Key : "test",
ContentType : "text/plain",
Body : new Date().toString()
};
bucket.upload(params, function(err, data) {
if (err)
alert("can't connect to s3");
else
console.log("s3 access granted");
});
}
function s3Upload(filename, type, data, callback) {
var bucket = new AWS.S3({
params : {
Bucket : s3bucket
}
});
var params = {
Key : filename,
ContentType : type,
Body : data
};
bucket.upload(params, function(err, data) {
if (err)
alert("can't upload");
else if (callback)
callback();
});
}