Kaynağa Gözat

Merge pull request #8 from newsdev/feature/gcs

James Thomas 6 yıl önce
ebeveyn
işleme
10f3f412a1
2 değiştirilmiş dosya ile 11 ekleme ve 6 silme
  1. 3 1
      Dockerfile
  2. 8 5
      lib/transports/s3/remote.js

+ 3 - 1
Dockerfile Dosyayı Görüntüle

@@ -8,8 +8,10 @@ WORKDIR /usr/src/app
8 8
 COPY package.json /usr/src/app/
9 9
 RUN apt-get update -y && apt-get upgrade -y && \
10 10
     apt-get install -y nodejs npm libcairo2-dev libjpeg62-turbo-dev libpango1.0-dev libgif-dev libpng-dev build-essential g++ ffmpeg
11
-COPY ./ /usr/src/app/
11
+COPY package.json* yarn.lock* .npmrc* /usr/src/app/
12 12
 RUN npm install --production
13 13
 
14
+COPY ./ /usr/src/app/
15
+
14 16
 EXPOSE 8888
15 17
 CMD [ "npm", "start" ]

+ 8 - 5
lib/transports/s3/remote.js Dosyayı Görüntüle

@@ -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 {