Hey Folks,

i try to upload files using GWT and GAE (Blobstore). Adding data to
the Datastore works fine already. When i click "Upload/Submit" it
opens a new Browser Window and it tries to open

http://xy.appspot.com/_ah/upload/saufdsgfdsfd98gdf89gfdgzfdg9fd78zf8f89fh3hhf938fj37f4

After a few seconds it ends with HTTP ERROR 500 with a Java Heap
Exception.


Here is my Code:

com.xy.client.MyProject.java
(...)
final FormPanel form = new FormPanel();
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
fileService.getUploadURL(new AsyncCallback<String>() {
   public void onFailure(Throwable error) {
   }
   public void onSuccess(String url) {
        form.setAction(url);                            // <<<-   
BLOBSTORE.REQUESTUPLOADURL HERE!
   }
});
(...)
myButton.addClickHandler(new ClickHandler() {
  @Override
  public void onClick(ClickEvent event) {
  form.submit();
}
(...)


com.xy.server.FileServerImpl.java
(...)
private BlobstoreService blobstoreService =
BlobstoreServiceFactory.getBlobstoreService();
public String getUploadURL() {
        String url = new String();
        url = blobstoreService.createUploadUrl("/xy/upload");
        return url;
}
(...)


com.xy.server.UploadFileServlet.java
(...)
public class UploadFileServlet extends HttpServlet {
        private BlobstoreService blobstoreService =
BlobstoreServiceFactory.getBlobstoreService();

        public void doPost(HttpServletRequest req, HttpServletResponse res)
                throws ServletException, IOException {
            Map<String, BlobKey> blobs =
blobstoreService.getUploadedBlobs(req);
            BlobKey blobKey = blobs.get("pdfFile");
        }
}
(...)


web.xml
(...)
  <servlet>
    <servlet-name>fileService</servlet-name>
    <servlet-class>com.gcx.gcpub.server.FileServiceImpl</servlet-
class>
  </servlet>

  <servlet>
    <servlet-name>uploadFileServlet</servlet-name>
    <servlet-class>com.gcx.gcpub.server.UploadFileServlet</servlet-
class>
  </servlet>

  <servlet-mapping>
    <servlet-name>fileService</servlet-name>
    <url-pattern>/gcpub/pdf</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>uploadFileServlet</servlet-name>
    <url-pattern>/gcpub/upload</url-pattern>
  </servlet-mapping>
(...)

I tried everything and I think I nearly read every thread on the web
handling this topic. Without GWT (if i use a JSP instead) it perfectly
works, it opens no new browser window and i even don't see the upload
URL generated by blobstoreService.createUploadUrl("/xy/upload").

Is it not possible to use a HttpServlet here to save the file to the
Blobstore? Can you tell me where is my mistake? I'm very thankful for
any help!

The docs for GWT and GAE are very good, doing some tutorials directly
pushes you the right way. Sadly there isn't as much good stuff for
combining GWT and GAE (don't even books).



-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to