GWT and CORS with file uploads

136 views
Skip to first unread message

Alan Chaney

unread,
Jun 21, 2011, 12:00:08 PM6/21/11
to google-we...@googlegroups.com
Hi

My company is developing a REST API for an asset management system and
we wish to add support for CORS both in the server (comparatively easy)
and also in GWT client applications.

One use case for this API is a GWT application where the user uploads a
file from their local filing system. So far, we've done this using the
GWT FormPanel and FileUpload classes. AFAIKS from looking at the code,
FileUpload uses a <form> element in an iframe. Experiments indicate that
cross-site uploads actually perform the transfer of data to the server,
but cookies and special headers are not sent, and the result comes out
as null. This is exactly as would be expected from reading the Mozilla
development docs.

As a simple test, I tried adding the Access-Control-Allow-Origin header,
but, of course, the '<form>' post doesn't generate the required OPTIONS
header and as far as firefox 4 is concerned, this is not a CORS request.

It seems to me that to properly support POST and PUT with content types
other than text/plain we need to properly implement an HTML5 form upload
script which uses the new FormData object. Does anyone have any
experience of AJAX support for CORS within GWT? If so, can they point me
to/share with me the code that they used?

Thanks in advance

Alan

Reply all
Reply to author
Forward
0 new messages