diff --git a/lib/storage-handler.js b/lib/storage-handler.js index 2cb9118..1497ef0 100644 --- a/lib/storage-handler.js +++ b/lib/storage-handler.js @@ -116,8 +116,10 @@ exports.download = function (provider, req, res, container, file, cb) { container: container || req && req.params.container, remote: file || req && req.params.file }); + res.type(file); reader.pipe(res); reader.on('error', function (err) { + res.type('application/json'); res.send(500, { error: err }); }); } diff --git a/test/upload-download.test.js b/test/upload-download.test.js index ae3bb54..c975f15 100644 --- a/test/upload-download.test.js +++ b/test/upload-download.test.js @@ -48,6 +48,7 @@ describe('storage service', function () { request('http://localhost:3000') .get('/containers/album1/download/test.jpg') + .expect('Content-Type', 'image/jpeg') .expect(200, function (err, res) { done(); }); @@ -57,6 +58,7 @@ describe('storage service', function () { request('http://localhost:3000') .get('/containers/album1/download/test_not_exist.jpg') + .expect('Content-Type', /json/) .expect(500, function (err, res) { assert(res.body.error); done();