fix inline detection
This commit is contained in:
parent
21bb3856b5
commit
768d10bb75
|
@ -94,10 +94,9 @@ handleGET = (req, file) ->
|
|||
headers['content-type'] = 'text/plain'
|
||||
|
||||
# Add content-disposition header to indicate file name
|
||||
if headers['content-type'].startsWith 'image/'
|
||||
headers['content-disposition'] = 'inline; filename=' + fileName
|
||||
else
|
||||
headers['content-disposition'] = 'attachment; filename=' + fileName
|
||||
inline = util.shouldShowInline headers['content-type']
|
||||
headers['content-disposition'] =
|
||||
(if inline then 'inline;' else 'attachment;') + ' filename=' + fileName
|
||||
|
||||
# Handle ranged resposes
|
||||
if resp.headers.has 'content-range'
|
||||
|
|
|
@ -32,10 +32,20 @@ idToPath = (id) ->
|
|||
id.split ''
|
||||
.join '/'
|
||||
|
||||
# Determine if we show something inline or not
|
||||
shouldShowInline = (mime) ->
|
||||
mime.startsWith 'text/' or
|
||||
mime.startsWith 'image/' or
|
||||
mime.startsWith 'audio/' or
|
||||
mime.startsWith 'video/' or
|
||||
mime == 'application/json' or
|
||||
mime == 'application/javascript'
|
||||
|
||||
export {
|
||||
getFileName,
|
||||
validateLength,
|
||||
MAX_UPLOAD_SIZE,
|
||||
randomID,
|
||||
idToPath
|
||||
idToPath,
|
||||
shouldShowInline
|
||||
}
|
Loading…
Reference in a new issue