Fix for issue #127

This commit is contained in:
Gary Torres 2016-06-14 11:20:24 -06:00
parent 2104efe438
commit a8fe32d78a
1 changed files with 5 additions and 3 deletions

View File

@ -5,6 +5,7 @@
var IncomingForm = require('formidable'); var IncomingForm = require('formidable');
var StringDecoder = require('string_decoder').StringDecoder; var StringDecoder = require('string_decoder').StringDecoder;
var path = require('path');
var defaultOptions = { var defaultOptions = {
maxFileSize: 10 * 1024 * 1024 // 10 MB maxFileSize: 10 * 1024 * 1024 // 10 MB
@ -196,7 +197,8 @@ function handleError(res, err) {
* @header storageService.download(provider, req, res, container, file, cb) * @header storageService.download(provider, req, res, container, file, cb)
*/ */
exports.download = function(provider, req, res, container, file, cb) { exports.download = function(provider, req, res, container, file, cb) {
var fileName = path.basename(file);
var params = { var params = {
container: container || req && req.params.container, container: container || req && req.params.container,
remote: file || req && req.params.file remote: file || req && req.params.file
@ -234,7 +236,7 @@ exports.download = function(provider, req, res, container, file, cb) {
var reader = provider.download(params); var reader = provider.download(params);
res.type(file); res.type(fileName);
reader.pipe(res); reader.pipe(res);
reader.on('error', function(err) { reader.on('error', function(err) {
@ -247,7 +249,7 @@ exports.download = function(provider, req, res, container, file, cb) {
var reader = provider.download(params); var reader = provider.download(params);
res.type(file); res.type(fileName);
reader.pipe(res); reader.pipe(res);
reader.on('error', function(err) { reader.on('error', function(err) {