This commit is contained in:
Steffen Jost 2019-05-17 13:40:39 +02:00
parent 86204f78e2
commit 601cbeab76

View File

@ -54,8 +54,9 @@ serveOneFile query = do
case results of case results of
[Entity _fileId File{fileTitle, fileContent}] [Entity _fileId File{fileTitle, fileContent}]
| Just fileContent' <- fileContent -> do | Just fileContent' <- fileContent -> do
whenM downloadFiles $ ifM downloadFiles
addHeader "Content-Disposition" [st|attachment; filename="#{takeFileName fileTitle}"|] (addHeader "Content-Disposition" [st|attachment; filename="#{takeFileName fileTitle}"|])
(addHeader "Content-Disposition" [st|inline; filename="#{takeFileName fileTitle}"|])
return $ TypedContent (mimeLookup (pack fileTitle) <> "; charset=utf-8") (toContent fileContent') return $ TypedContent (mimeLookup (pack fileTitle) <> "; charset=utf-8") (toContent fileContent')
| otherwise -> sendResponseStatus noContent204 () | otherwise -> sendResponseStatus noContent204 ()
[] -> notFound [] -> notFound
@ -72,8 +73,9 @@ serveSomeFiles archiveName query = do
[] -> notFound [] -> notFound
[Entity _fileId File{fileTitle, fileContent}] [Entity _fileId File{fileTitle, fileContent}]
| Just fileContent' <- fileContent -> do | Just fileContent' <- fileContent -> do
whenM downloadFiles $ ifM downloadFiles
addHeader "Content-Disposition" [st|attachment; filename="#{takeFileName fileTitle}"|] (addHeader "Content-Disposition" [st|attachment; filename="#{takeFileName fileTitle}"|])
(addHeader "Content-Disposition" [st|inline; filename="#{takeFileName fileTitle}"|])
return $ TypedContent (mimeLookup (pack fileTitle) <> "; charset=utf-8") (toContent fileContent') return $ TypedContent (mimeLookup (pack fileTitle) <> "; charset=utf-8") (toContent fileContent')
| otherwise -> sendResponseStatus noContent204 () | otherwise -> sendResponseStatus noContent204 ()
files -> do files -> do