Merge pull request #129 from GaryTowers/fix/issue-127-bad-content-type

Fixes issue #127 (Bad Content-type returned)
This commit is contained in:
Simon Ho 2016-06-14 16:56:37 -07:00 committed by GitHub
commit 9c75ee80bc
1 changed files with 5 additions and 3 deletions

View File

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