I'm trying to set up a file upload in my application based on
SwfUploader (http://swfupload.org), and I'm coming to my wits end
about how to proceed. I use Tapestry5 for my application (http://
tapestry.apache.org/tapestry5.1) but I think for the most part that's
beside the point.

First, I create a servlet mapped to a path (/postUpload) that is used
in generating the Blobstore upload URL using the BlobStoreService.
When I generate an upload URL and point a single file upload to that
URL using the SwfUploader, the first file is uploaded successfully.
However,  one of the big benefits of SwfUploader is the ability to
queue up multiple files to be uploaded. The problem is that after the
first file is uploaded to the given URL, the subsequent file uploads
to the same URL fail (as evidently, the Blobstore prefers to have a
separate URL for each upload). OK, I accept that as a choice of the
API.

Now, because the blobstore API and SwfUploader are third party
components, I have to have something in the middle that mediates the
differences. The solution I came up with is as follows:
1. Create a servlet (e.g. mapped to /upload) to which the SwfUploader
submits all requests.
2. Configure SwfUPloader to post to that URL
3. Configure the servlet to generate a new BlobstoreSErvice URL for
each request and then use the request.getRequestDispatcher("...
blobstore generated url...").forward(request,response).

In this way, all the third party pieces should be happy : SwfUPloader
gets to upload to the same URL every time, and the Blobstore is
receives an upload to a new URL every time. Now, in the dev server,
this approach works beautifully, my files get uploaded and I can see
them in the dev server blobstore.

Now, the problem : when I upload my app to GAE, the file upload stops
working, I start getting 404 errors and the files do not get uploaded.
I think that I eliminated the first problem : in production GAE
blobstoreService generates absolute URLs  : e.g. while the dev server
generated /_ah/upload?d.....dsf... URLs, in prod they are
http://foo.com/_ah/upload... and AFAIK, the request dispatcher
requires a path (e.g. /foo/bar) with the app, not an absolute URL
(e.g. http://foo.com/_ah/upload...).

I tried tackling the issue by just stripping out the server name from
the Blobstore generated URL, but to no avail. I continue getting the
same 404 errors. Just for a good measure, if I comment out the passing
of the original request and response to the request dispatcher, the
servlet responds just fine (that is, I wanted to make sure that the
servlet is properly mapped, etc).

So, I'm stumped. The only possible next step to get this working would
be to hack up SwfUploader so that I can specify a different URL for
each submission. I thought about using the URL fetch service to send a
POST to the blobstore URLs, but I'm not sure how I can add the
uploaded file data.

I like the Blobstore API in that it gives a decent solution to the
fileupload problem and I'd like to use the Blobstore. If that doesn't
work, I guess I'd have to go back to uploading into a blob in the
database using my own code (and dealing w/ the subsequent restrictions
- e.g. 1 MB entity, etc).

Any tips ? Ideas of where I should proceed to ?
-- 
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.


Reply via email to