i have file linked object byte[]. file stored in db in blob column type , binding made @lob annotation.
the problem system doesn't manage file type (ie : upload pdf when download it, doesn't have type)
can give me easy way deal type of issue ?
my first thought store type in simple varchar column how change type of stream on byte[] getter ?
imho you'r right using separate field mimetype lob content. can during upload deduce mimetype store jpa entity.
in download servlet, can write :
string mimetype = entity.getmimetype(); // sets response content type if (mimetype == null) { mimetype = "application/octet-stream"; } response.setcontenttype(mimetype); response.setcontentlength((int)file.length()); string filename = (new file(filepath)).getname(); // sets http header response.setheader("content-disposition", "attachment; filename=\"" + filename + "\"");
Comments
Post a Comment