Set Content-Type based on the file path
This commit is contained in:
parent
e853235e82
commit
eb0d9a11bf
|
@ -116,8 +116,10 @@ exports.download = function (provider, req, res, container, file, cb) {
|
||||||
container: container || req && req.params.container,
|
container: container || req && req.params.container,
|
||||||
remote: file || req && req.params.file
|
remote: file || req && req.params.file
|
||||||
});
|
});
|
||||||
|
res.type(file);
|
||||||
reader.pipe(res);
|
reader.pipe(res);
|
||||||
reader.on('error', function (err) {
|
reader.on('error', function (err) {
|
||||||
|
res.type('application/json');
|
||||||
res.send(500, { error: err });
|
res.send(500, { error: err });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ describe('storage service', function () {
|
||||||
|
|
||||||
request('http://localhost:3000')
|
request('http://localhost:3000')
|
||||||
.get('/containers/album1/download/test.jpg')
|
.get('/containers/album1/download/test.jpg')
|
||||||
|
.expect('Content-Type', 'image/jpeg')
|
||||||
.expect(200, function (err, res) {
|
.expect(200, function (err, res) {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -57,6 +58,7 @@ describe('storage service', function () {
|
||||||
|
|
||||||
request('http://localhost:3000')
|
request('http://localhost:3000')
|
||||||
.get('/containers/album1/download/test_not_exist.jpg')
|
.get('/containers/album1/download/test_not_exist.jpg')
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
.expect(500, function (err, res) {
|
.expect(500, function (err, res) {
|
||||||
assert(res.body.error);
|
assert(res.body.error);
|
||||||
done();
|
done();
|
||||||
|
|
Loading…
Reference in New Issue