Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Attachment: treat error if file doesn't exists on storage
Browse files Browse the repository at this point in the history
Response as 500 Internal Server Error and log it as error.
  • Loading branch information
laziel committed Aug 14, 2014
1 parent df9a8d4 commit c366aff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/AttachmentApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public static Result getFile(Long id) throws IOException {

File file = attachment.getFile();

if(file != null && !file.exists()){
Logger.error("Attachment ID:" + id + " (" + file.getAbsolutePath() + ") does not exist on storage");
return internalServerError("The file does not exist");
}

String filename = HttpUtil.encodeContentDisposition(attachment.name);

response().setHeader("Content-Type", attachment.mimeType);
Expand Down

0 comments on commit c366aff

Please sign in to comment.