I stared by searching on the web on how to save a file as a blob to the datastore after a bit of playing I managed to get it all working using JSP pages and the apache commons fileupload, using this little bit of code:
The full source is available on github.ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iter; iter = upload.getItemIterator(req); FileItemStream fileItem;
while(iter.hasNext() == true) { fileItem = iter.next(); InputStream fileStream = fileItem.openStream(); Blob imageBlob = new Blob(IOUtils.toByteArray(fileStream)); if (fileItem.getContentType() != null) FileDAL.createFile(fileItem.getName(), fileItem.getContentType(), imageBlob); }
I have decided that I really hate JSP Pages so I am going to look into a different template engine stay tuned...
No comments:
Post a Comment