Re: [appengine-java] Re: How to upload pics in appengine java
Hi Friends i try to use the below code but i got an error at *PhotoServlet as* * * *Photo photo = PhotoDao.getInstance().getById(Long.parseLong(id));* The method getById(long) is undefined for the type PhotoDao can any body help for this? -- ThanksRegards, Nagarjuna Ch Hyderabad,India Mobile:+91-9949000658 | Whoever is happy will make others happy too. 2010/3/15 rissen risse...@gmail.com Step1:Defining a data class named Photo public class Photo{ @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long id; @Persistent private Blob photo; ... Set Get ... } Step2:Defining a DAO PhotoDAO.java public class PhotoDao { private static PhotoDao _instance = null; public static PhotoDao getInstance() { if (_instance == null) { _instance = new PhotoDao(); } return _instance; } // public String insertPhoto(Photo photo) { PersistenceManager pm = PMF.get().getPersistenceManager(); try { pm.makePersistent(photo); } finally { pm.close(); } return photo.getId().toString(); } } Step3:UploadServlet.java import org.apache.commons.fileupload.FileItemIterator; import org.apache.commons.fileupload.FileItemStream; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.io.IOUtils; UploadServlet.java ... ... ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iterator = null; try { iterator = upload.getItemIterator(req); } catch (FileUploadException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { while (iterator.hasNext()) { FileItemStream item = iterator.next(); InputStream stream = item.openStream(); if (item.isFormField()) { // Handle form field } else { // Handle the uploaded file Blob bImg = new Blob(IOUtils.toByteArray(stream)); Photo photo = new Photo(bImg); String pid = PhotoDao.getInstance().insertPhoto(photo); //resp.sendRedirect(admin?type=photooption=list); } } ... ... Step4: Show the photo which you upload. PhotoSerlvet.java public class PhotoServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String id = req.getParameter(id); ... Photo photo = PhotoDao.getInstance().getById(Long.parseLong(id)); ... Blob b = photo.getPhoto(); resp.setContentType(image/jpeg;charset=utf-8); resp.getOutputStream().write(b.getBytes()); resp.getOutputStream().close(); } } demo: http://mimaiji.appspot.com/photo?id=4001 On 3月14日, 下午1时12分, nag nagarjuna...@gmail.com wrote: Hi I am trying to build online reg form can u help me how to upload image files to app engine. First: is there any way to upload images in app engine? thanks Nag -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
[appengine-java] Re: How to upload pics in appengine java
Also this guy Vince has a package that not only helps with uploads but also then allowing your app to generate pages that use the photos including delta checks - really neat stuff! See GAEVFS mentioned in this thread. Please post your results so the rest of us can benefit from your experience. http://groups.google.com/group/google-appengine-java/browse_thread/thread/a4ee0a7c54453586/b1f2984b43c920a1?hl=en#b1f2984b43c920a1 On Mar 14, 12:51 am, seleronm seler...@gmail.com wrote: Hi, I think that the following links are useful.http://stackoverflow.com/questions/1513603/ Please try. thanks. AFAIK almost any file can be apart of the docs that you upload (images, css, html, js, jsp, ico). I haven't had any trouble uploading images. Are you talking about accepting images from an input form? In that case you can store them as a blob type in the datastore. Hope this helps On Sun, Mar 14, 2010 at 12:12 AM, nag nagarjuna...@gmail.com wrote: Hi I am trying to build online reg form can u help me how to upload image files to app engine. First: is there any way to upload images in app engine? thanks Nag -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java% 2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en. -- -Pav -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+ unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/google- appengine-java?hl=en. ---html-part included links--- mailto:nagarjuna...@gmail.com mailto:google-appengine-java@googlegroups.com mailto:google-appengine-java%2bunsubscr...@googlegroups.com http://groups.google.com/group/google-appengine-java?hl=en- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
Re: [appengine-java] Re: How to upload pics in appengine java
a simple demo here: http://hapeblog.appspot.com/blog.shtml?id=2002 On Mon, Mar 15, 2010 at 11:17 AM, Diana Cruise diana.l.cru...@gmail.comwrote: Also this guy Vince has a package that not only helps with uploads but also then allowing your app to generate pages that use the photos including delta checks - really neat stuff! See GAEVFS mentioned in this thread. Please post your results so the rest of us can benefit from your experience. http://groups.google.com/group/google-appengine-java/browse_thread/thread/a4ee0a7c54453586/b1f2984b43c920a1?hl=en#b1f2984b43c920a1 On Mar 14, 12:51 am, seleronm seler...@gmail.com wrote: Hi, I think that the following links are useful. http://stackoverflow.com/questions/1513603/ Please try. thanks. AFAIK almost any file can be apart of the docs that you upload (images, css, html, js, jsp, ico). I haven't had any trouble uploading images. Are you talking about accepting images from an input form? In that case you can store them as a blob type in the datastore. Hope this helps On Sun, Mar 14, 2010 at 12:12 AM, nag nagarjuna...@gmail.com wrote: Hi I am trying to build online reg form can u help me how to upload image files to app engine. First: is there any way to upload images in app engine? thanks Nag -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java%2bunsubscr...@googlegroups.com google-appengine-java% 2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en. -- -Pav -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+ unsubscr...@googlegroups.com. For more options, visit this group athttp:// groups.google.com/group/google- appengine-java?hl=en. ---html-part included links--- mailto:nagarjuna...@gmail.com mailto:google-appengine-java@googlegroups.com mailto:google-appengine-java%2bunsubscr...@googlegroups.comgoogle-appengine-java%252bunsubscr...@googlegroups.com http://groups.google.com/group/google-appengine-java?hl=en- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en. -- dream or truth -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.