Don't keep your files in DB, filesystem is much better for that! Save uploaded file on the disk with some unique name, then in your database keep only path to the file as a String
!
- It's cheaper in longer run (as said many times)
It's easier to handle downloads, i.e. in Play all you need to serve PDF is:
public static Result download() { File file = new File("/full/path/to/your.pdf"); return ok(file); }
it will set proper headers, like Content-Disposition
, Content-Length
and Content-Type
not only for PDFs