Skip to content

Commit

Permalink
Merge pull request #26 from feedhenry/update-multer-dependency
Browse files Browse the repository at this point in the history
Update multer dependency
  • Loading branch information
matskiv authored Feb 2, 2018
2 parents b27a451 + fc8f202 commit 522e216
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 35 deletions.
12 changes: 10 additions & 2 deletions lib/cloud/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@ var cloud = {
next();
});

app.use(multer({ dest: '/tmp'}));
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, '/tmp')
},
filename: function (req, file, cb) {
cb(null, file.originalname)
}
})
var upload = multer({storage: storage})
app.use(bodyParser.json({"limit": "10mb"}));

// Process GETs, POSTs, and everything else inbetween!
// Do clever jsonp stuff, and make one unified params object
app.all('/:func', function (req, res) {
app.all('/:func', upload.any(), function (req, res) {
var params = {};
params = paramsUtils.normalise(params, req);
return cloud.callFunction(params, req, res);
Expand Down
2 changes: 1 addition & 1 deletion lib/common/requestValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ module.exports = function(request){

for(var fileEntry in filesInRequest){
params.submission.fileStream = filesInRequest[fileEntry].path;
params.submission.fileName = filesInRequest[fileEntry].name;// In this case, the name is the hash name "filePlaceHolder325346234234634646"
params.submission.fileName = filesInRequest[fileEntry].filename;// In this case, the name is the hash name "filePlaceHolder325346234234634646"
}

return cb(undefined, params);
Expand Down
17 changes: 13 additions & 4 deletions lib/mbaas.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,20 @@ function handleError(err, res){
// connect.router(function (app) {
var app = express.Router();
app.use(cors());
app.use(multer({ dest: '/tmp'}));
app.use(bodyParser.json({"limit": "10mb"}));
app.use(bodyParser.urlencoded({ extended: false }));

app.post('/:api', handleRequest);
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, '/tmp')
},
filename: function (req, file, cb) {
cb(null, file.originalname)
}
})
var upload = multer({storage: storage})

app.post('/:api', upload.any(), handleRequest);

app.get('/sync/stats', function(req, res){
if (fh.sync && fh.sync.getStats) {
Expand Down Expand Up @@ -296,7 +305,7 @@ var app = express.Router();
});
});

app.post('/forms/:appId/:submitId/:fieldId/:fileId/submitFormFile', function(req, res){
app.post('/forms/:appId/:submitId/:fieldId/:fileId/submitFormFile', upload.any(), function(req, res){
var requestValidator = reqValidator(req);

applyAuth(req, res, "forms", undefined, function(err, ok){
Expand All @@ -316,7 +325,7 @@ var app = express.Router();
});
});

app.post('/forms/:appId/:submitId/:fieldId/:fileId/submitFormFileBase64', function(req, res){
app.post('/forms/:appId/:submitId/:fieldId/:fileId/submitFormFileBase64', upload.any(), function(req, res){
var requestValidator = reqValidator(req);

applyAuth(req, res, "forms", undefined, function(err, ok){
Expand Down
131 changes: 107 additions & 24 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fh-mbaas-express",
"version": "5.9.2",
"version": "5.10.0",
"description": "FeedHenry MBAAS Express",
"main": "lib/webapp.js",
"dependencies": {
Expand All @@ -11,7 +11,7 @@
"fh-amqp-js": "0.7.1",
"fh-mbaas-client": "0.16.5",
"fh-reportingclient": "0.5.7",
"multer": "0.1.8",
"multer": "1.3.0",
"request": "2.81.0",
"type-is": "~1.2.1",
"underscore": "1.5.1"
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.projectKey=fh-mbaas-express
sonar.projectName=fh-mbaas-express-nightly-master
sonar.projectVersion=5.9.2
sonar.projectVersion=5.10.0

sonar.sources=./lib
sonar.tests=./test
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_requestValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module.exports = {
"files": [
{
"path": "/some/file/path",
"name": "somefileName"
"filename": "somefileName"
}
]
};
Expand Down

0 comments on commit 522e216

Please sign in to comment.