Alex
Alex

Reputation:

GWT Toolkit: preprocessing files on client side

If there's a way for the client side GWT code to pre-process a file on the client computer? For example, to calculate a checksum of it before submitting the file to the server.

Upvotes: 2

Views: 3480

Answers (4)

Vincent
Vincent

Reputation: 11

Using GWT, there is no way to read files on the client side yet. However, in HTML5, you can read files without uploading to a server using the "File API".

Links are provided below.

File API tutorial on html5rocks.com

Example of how to use File API in GWT via JSNI

Upvotes: 1

Thierry Roy
Thierry Roy

Reputation: 8502

No it is not possible. The manipulation of the file is done by the browser, not the HTML code.

Think about it, GWT is 100% javascript. And javascript has no access whatsoever of the file in your computer. That would be an pretty big security risk! GWT "wraps" the file input box so it can be displayed inside the GWT panel. But once you press the "upload" button, the upload is done by the browser.

You could do file manipulation with another technology however. Java applets for example. But that is outside of GWT area...

Upvotes: 2

gavinandresen
gavinandresen

Reputation: 551

Do you mean from an <input type="file"...> file upload field in a form?

The short answer is no-- file uploads are handled by the browser, and are sent directly to the server (as an ENCODING_MULTIPART POST). And security restrictions on JavaScript mean there's no way to workaround that restriction.

Upvotes: 0

Sophie Alpert
Sophie Alpert

Reputation: 143104

I'm pretty sure that because GWT code compiles to pure JavaScript, there isn't a way without requiring some third-party browser plugin.

Upvotes: 0

Related Questions