I'm trying to upload to the blobstore by programattically creating the POST 
request using the following class:

MultiPartFormOutputStream<http://svn.apache.org/repos/asf/wicket/branches/wicket-1.2.x/wicket-sandbox/src/jonathan/java/wicket/util/upload/MultiPartFormOutputStream.java>

             BlobstoreService blobstoreService = 
BlobstoreServiceFactory.getBlobstoreService();
             try
             {
                     uploadURL = 
blobstoreService.createUploadUrl("/upload");
             }
             catch(BlobstoreFailureException e)
             {
                    resp.sendRedirect("close.jsp");
             }
             
             //add host if in dev mode
             if(uploadURL.indexOf("http") == -1)
             {
                 uploadURL = "http://localhost:8888"; + uploadURL;
             }
             URL url = new URL(uploadURL);
             // create a boundary string

             String boundary = MultiPartFormOutputStream.createBoundary();
             URLConnection urlConn = 
MultiPartFormOutputStream.createConnection(url); 
             urlConn.setReadTimeout(30000);
             urlConn.setConnectTimeout(30000);
             urlConn.setRequestProperty("Accept", "*/*");
             urlConn.setRequestProperty("Content-Type", 
MultiPartFormOutputStream.getContentType(boundary));
             urlConn.setRequestProperty("Cookie", name + "=" + value);
             // set some other request headers...
             urlConn.setRequestProperty("Connection", "Keep-Alive");
             // no need to connect because getOutputStream() does it     

         MultiPartFormOutputStream out = null; 
            try
            {
             out = new MultiPartFormOutputStream(urlConn.getOutputStream(), 
boundary);
             // write a text field element
             out.writeField("old", oldBlobKey);
             out.writeField("topic", topic);
             out.writeField("category", category);
             out.writeField("key", key);
             // write bytes directly
             out.writeFile("myFile", "text/html", "content.html", htmlData);
             out.close();
            }
            catch(IOException e)
            {
                resp.sendRedirect("close.jsp");
            }

Even when it times out  uploading and an exception gets thrown, the byte 
array still gets uploaded and the content.html file gets updated...I'm now 
sure how that works. I tried catching the exception with the above code, but 
sometimes it STILL displays an erro rmessage saying there was an uncaught 
IOException.

1.) Why is app-engine timing out when  uploading a file that is <5k in size?
2.) Why is it that even when I am attempting to catch the exception after 
creating the connection to the upload URL (in the case of the timeout), it 
still comes back as an uncaught exception...

Any help would be greatly appreciated! I really need to figure out why this 
Timeout is occurring....I see people who talk about uploading files 
>1MB...how is it that my tiny HTML files timeout when being uploaded to the 
Blobstore?
 

-- 
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