|
@@ -3,7 +3,11 @@ var AWS = require("aws-sdk"),
|
3
|
3
|
|
4
|
4
|
module.exports = function(bucket, storagePath) {
|
5
|
5
|
|
6
|
|
- var s3 = new AWS.S3({ params: { Bucket: bucket } });
|
|
6
|
+ var s3Options = { params: { Bucket: bucket } };
|
|
7
|
+ if (process.env.S3_ENDPOINT) {
|
|
8
|
+ s3Options.endpoint = process.env.S3_ENDPOINT;
|
|
9
|
+ }
|
|
10
|
+ var s3 = new AWS.S3(s3Options);
|
7
|
11
|
|
8
|
12
|
// Test credentials
|
9
|
13
|
s3.headBucket({}, function(err){ if (err) { throw err; } });
|
|
@@ -12,12 +16,11 @@ module.exports = function(bucket, storagePath) {
|
12
|
16
|
|
13
|
17
|
var params = {
|
14
|
18
|
Key: storagePath + key,
|
15
|
|
- Body: fs.createReadStream(source),
|
16
|
|
- ACL: "public-read"
|
|
19
|
+ Body: fs.createReadStream(source)
|
17
|
20
|
};
|
18
|
21
|
|
19
|
22
|
// gzipping results in inconsistent file size :(
|
20
|
|
- s3.upload(params, cb);
|
|
23
|
+ s3.putObject(params, cb);
|
21
|
24
|
|
22
|
25
|
}
|
23
|
26
|
|
|
@@ -71,7 +74,7 @@ module.exports = function(bucket, storagePath) {
|
71
|
74
|
|
72
|
75
|
// TODO make this more configurable
|
73
|
76
|
function getURL(id) {
|
74
|
|
- return "https://s3.amazonaws.com/" + bucket + "/" + storagePath + "video/" + id + ".mp4";
|
|
77
|
+ return "https://" + bucket + "/" + storagePath + "video/" + id + ".mp4";
|
75
|
78
|
}
|
76
|
79
|
|
77
|
80
|
return {
|