java - A one step upload for uploading images using google app engine -


i trying implement basic functionality of uploading images android,iphone , web clients google app engine. did initial version of implementation this blog:

however there seems 2 step process uploading image:

  1. get initial upload url post using createuploadurl(). attaching fragment of code use :
     public class createuploadurl extends httpservlet {      @override     public void doget(httpservletrequest req, httpservletresponse resp) throws ioexception {         blobstoreservice blobstoreservice = blobstoreservicefactory.getblobstoreservice();         string uploadurl = blobstoreservice.createuploadurl("/image/uploadimage");         resp.setcontenttype("text/plain");         resp.getwriter().println(uploadurl);     } }  
  1. post image using url "got"
      public void dopost(httpservletrequest req, httpservletresponse res) throws servletexception, ioexception {         blobkey blobkey = parameterextractor.getblobparameter(req, "blob-key", blobstoreservice);         if (blobkey == null) {             log.info("blob id null. post failed");         } else {             log.info("ze business logic");         }     } 

my question if possible in 1 step since right clients need http get upload url , http post post image.

is not possible 1 http post predefined url.

thanks rajat

this possible, limitations. can bypass uploadurl mechanism creating blobs directly in servlet using (currently experimental) createnewblobfile api. in mobile app(s) create http request encoded multipart/form-data, , teach servlet how decode such thing (consult e.g. how upload files in jsp/servlet?). aware http requests limited 32mb; form encoding amount of binary data can upload less that.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -