Commit ffb7f301 authored by mntmn's avatar mntmn
Browse files

switch between s3/local storage in config

parent 8ee33864
{
"endpoint": "http://localhost:9000",
"storage_bucket": "my_spacedeck_s3_bucket",
"storage_cdn": "xyz.cloudfront.net",
"storage_region": "eu-central-1",
"storage_bucket": "my_spacedeck_bucket",
"storage_cdn": "/storage",
"storage_local_path": "./storage",
"google_access" : "",
"google_secret" : "",
"admin_pass": "very_secret_admin_password",
......
'use strict';
var AWS = require('aws-sdk');
AWS.config.region = 'eu-central-1';
var fs = require('fs');
var config = require('config');
// use AWS S3 or local folder depending on config
if (config.get("storage_local_path")) {
var AWS = require('mock-aws-s3');
AWS.config.basePath = config.get("storage_local_path");
} else {
var AWS = require('aws-sdk');
AWS.config.region = config.get("storage_region");
}
module.exports = {
removeFile: (path, callback) => {
const s3 = new AWS.S3({
region: 'eu-central-1'
region: config.get("storage_region")
});
const bucket = config.get("storage_bucket");
s3.deleteObject({
......@@ -39,9 +45,8 @@ module.exports = {
}
});
fileStream.on('open', function () {
// FIXME
var s3 = new AWS.S3({
region: 'eu-central-1'
region: config.get("storage_region")
});
s3.putObject({
......@@ -54,7 +59,7 @@ module.exports = {
console.error(err);
callback(err);
}else {
const url = "https://"+ config.get("storage_cdn") + "/" + fileName;
const url = config.get("storage_cdn") + "/" + fileName;
console.log("[s3]" + localFilePath + " to " + url);
callback(null, url);
}
......
......@@ -6,8 +6,8 @@
"start": "nodemon -e .js,.html bin/www",
"test": "mocha"
},
"engines" : {
"node" : ">=7.8.0"
"engines": {
"node": ">=7.8.0"
},
"dependencies": {
"archiver": "1.3.0",
......@@ -28,7 +28,6 @@
"googleapis": "18.0.0",
"gulp": "^3.9.1",
"gulp-concat": "2.6.0",
"gulp-eslint": "*",
"gulp-express": "0.3.0",
"gulp-nodemon": "*",
"gulp-sass": "^2.0.3",
......@@ -40,13 +39,13 @@
"lodash": "^4.3.0",
"log-timestamp": "latest",
"md5": "2.2.1",
"mock-aws-s3": "^2.6.0",
"moment": "2.18.1",
"mongoose": "4.9.3",
"morgan": "1.8.1",
"node-phantom-simple": "2.2.4",
"node-sass-middleware": "0.11.0",
"pdfkit": "0.8.0",
"validator": "7.0.0",
"node-phantom-simple": "2.2.4",
"phantomjs-prebuilt": "2.1.14",
"pm2": "latest",
"qr-image": "3.2.0",
......@@ -54,9 +53,11 @@
"request": "2.81.0",
"sanitize-html": "^1.11.1",
"serve-favicon": "~2.4.2",
"swig": "1.4.2",
"serve-static": "^1.13.1",
"slug": "0.9.1",
"swig": "1.4.2",
"underscore": "1.8.3",
"validator": "7.0.0",
"weak": "1.0.1",
"ws": "2.2.3"
},
......@@ -65,7 +66,6 @@
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-eslint": "^3.0.1",
"gulp-express": "^0.3.0",
"gulp-fingerprint": "^0.3.2",
"gulp-nodemon": "^2.0.4",
......@@ -81,8 +81,7 @@
},
"description": "",
"main": "Gulpfile.js",
"directories": {
},
"directories": {},
"repository": {
"type": "git",
"url": "https://github.com/spacedeck/spacedeck-open.git"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment