forked from tjek/tjek-js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload-s3.js
36 lines (32 loc) · 1 KB
/
upload-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
var AWS = require('aws-sdk');
var fs = require('fs');
var path = require('path');
var pkg = require('./package');
var credentials = new AWS.SharedIniFileCredentials({ profile: 'shopgun-js-sdk' });
var bucket = 'sgn-js-sdk';
AWS.config.credentials = credentials;
function putObject (options) {
new AWS.S3().putObject({
Bucket: bucket,
Key: options.key,
Body: fs.readFileSync(options.bodyPath).toString(),
ACL: 'public-read',
ContentType: options.contentType
}, function (err, data) {
if (err) {
console.log('Could not upload ' + options.key);
} else {
console.log('Uploaded ' + options.key);
}
});
}
putObject({
key: 'sgn-sdk-' + pkg.version + '.min.js',
bodyPath: path.join(__dirname, 'dist', 'sgn-sdk.min.js'),
contentType: 'application/javascript'
});
putObject({
key: 'sgn-sdk-' + pkg.version + '.min.css',
bodyPath: path.join(__dirname, 'dist', 'sgn-sdk.min.css'),
contentType: 'text/css'
});