Howto use the HTML5 file API in GWT 2.7

To access HTML5 features in GWT 2.7 the elemental package must be used, but the HTML5 file API implementations are chrome dependend because at the time it was written the standards were far away. Nowadays the file API is implemented in all main browsers: IE11, Chrome, Firefox & Safari.

In this Blogpost I want to show how the elemental package can be used with theĀ  generic HTML5 file API.

Enable GWT elemental in the project:

Custom implementation of the input file element where the user selects the files that should be accessed:

The Html5FileList class just provides an additional method that returns our custom Html5File class:

The Html5File class is where the *magic* happens because the GWT implementation of JsBlob and JsFile use chrome dependend javascript code:

And finally after creating the MultipleFileUpload element you add an change event handler which is called after the user has selected file(s):