Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

added cache-control header #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ MongoStorage = (function() {
read = gfs.createReadStream({
_id: file._id
});
res.set('Cache-Control', 'public, max-age=86400000');
res.set('Content-Disposition', "attachment; filename=\"" + file.filename + "\"");
res.set('Content-Type', file.metadata.mimetype);
res.set('Content-Length', file.length);
Expand Down
3 changes: 2 additions & 1 deletion source/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class MongoStorage
'metadata.container': container
, (err, files) ->
return callback err, files

removeFile: (container, filename, callback) ->
@db.collection 'fs.files'
.remove
Expand Down Expand Up @@ -132,6 +132,7 @@ class MongoStorage
gfs = Grid self.db, mongodb
read = gfs.createReadStream
_id: file._id
res.set 'Cache-Control', 'public, max-age=86400000'
res.set 'Content-Disposition', "attachment; filename=\"#{file.filename}\""
res.set 'Content-Type', file.metadata.mimetype
res.set 'Content-Length', file.length
Expand Down