Skip to main content

Home/ Google AppEngine/ Group items tagged gwtupload

Rss Feed Group items tagged

Esfand S

Example of using new GAE libs - gwtupload | Google Groups - 0 views

  • public class DatastoreUploadAction extends AppEngineUploadAction {         @Override         public String executeAction(HttpServletRequest request, List<FileItem> sessionFiles) throws UploadActionException {                 String out = super.executeAction(request, sessionFiles);                 for(FileItem imgItem : sessionFiles) {                         PersistenceManager pm = ContentServiceImpl.getPersistenceManager();                         Transaction tx = pm.currentTransaction();                         try {                             // Start the transaction                             tx.begin();                             InputStream imgStream = imgItem.getInputStream();                                 Blob blob = new Blob(IOUtils.toByteArray(imgStream));                                 ImageBlob imageBlob = new ImageBlob(imgItem.getName(), blob);                             pm.makePersistent(imageBlob);                             // Commit the transaction, flushing the object to the datastore                             tx.commit();                         }                         catch(Exception e) {                                 e.printStackTrace();                         }                         finally {                             if(tx.isActive()) {                                 tx.rollback();                             }                             pm.close();                         }                 }             return out;         } }
1 - 2 of 2
Showing 20 items per page