Wednesday, March 7, 2012

[YouTube-API] Re: to upload image using webservice.

Hello Bipin,

I believe you're posting in the wrong forum. This is the YouTube API
Google Group.

Cheers,
-Jeff Posnick, YouTube API Team
groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
@YouTubeDev


On Mar 3, 2:23 am, dev doigetit <doige...@gmail.com> wrote:
> Hello I am making webservice for iPhone and in that i want to upload
> an image in blobstore . Now the request is sended from iPhon side with
> the use of uploaded url:"http://doigetit.appspot.com/_ah/upload/" and
> i used that request in the below code:
>
> public class Upload extends HttpServlet {
>
>                 private BlobstoreService
> blobstoreService=BlobstoreServiceFactory.getBlobstoreService();
>
>                 public void doGet(HttpServletRequest req, HttpServletResponse res){
>                         System.out.println("hello");
>                         }
>
>                 public void doPost(HttpServletRequest req, HttpServletResponse res){
>
>                         EntityManagerFactory emf_upload= EMFService.get();
>                         EntityManager em= emf_upload.createEntityManager();
>                         HttpServletRequest rec = req;
>
>                         @SuppressWarnings("deprecation")
>                         Map<String, BlobKey> blobs= blobstoreService.getUploadedBlobs(req);
>                         BlobKey blobKey= blobs.get("myFile");
>                         String productid=req.getParameter("productId");
>
>                         em.getTransaction().begin();
>                         //Key k =
> KeyFactory.createKey(Productrequestdetails.class.getSimpleName(),
> productid);
>                         Productrequestdetails p =
> em.find(Productrequestdetails.class,"agpzfmRvaWdldGl0chwLEhVwcm9kdWN0cmVxdW VzdGRldGFpbHMY-
> VUM");
>                 p.setSzProductUrl("http://doigetit.appspot.com/serve?blob-
> key="+blobKey.getKeyString());
>
>                 em.merge(p);
>                 em.getTransaction().commit();
>
>                         em.clear();
>                         em.close();
>
>                         emf_upload.close();
>
>                 }
>
> }
>
> But that code is not work and gives an error like:
>
> java.lang.IllegalStateException: Must be called from a blob upload
> callback request.
>         at
> com.google.appengine.api.blobstore.BlobstoreServiceImpl.getUploads(Blobstor eServiceImpl.java:
> 158)
>         at
> com.google.appengine.api.blobstore.BlobstoreServiceImpl.getUploadedBlobs(Bl obstoreServiceImpl.java:
> 135)
>         at com.google.doigetit.Upload.doPost(Upload.java:40)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>         at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
> 511)
>         at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1166)
>         at
>
> so, if anyone knows the idea about it then please guide me to run my
> code and upload image fine.
>
> Thanks,
> Bipin Vekariya.

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment