gwtquery
gwtquery copied to clipboard
FileUpload not working in Android native Browser (webkit 534.30)
Uploading files on Android native browser is not working with GQuery.
I tried this:
// Use gQuery utils to create a FormData object instead
// of JSNI
JavaScriptObject form = JsUtils.runJavascriptFunction(window, "eval",
"new FormData()");
JsUtils.runJavascriptFunction(form, "append", "image", file);
// Use gQuery ajax instead of RequestBuilder because it
// supports FormData and progress
Ajax.ajax(Ajax.createSettings().setUrl(url).setData((Properties) form))
// gQuery ajax returns a promise, making the code more
// declarative
.progress(new Function() {
public void f() {
double total = arguments(0);
double done = arguments(1);
double percent = arguments(2);
// Here you can update your progress bar
GWT.log("Uploaded " + done + "/" + total + " ("
+ percent + "%)");
}
}).done(new Function() {
public void f() {
GWT.log("Files uploaded, server response is: "
+ arguments(0));
}
}).fail(new Function() {
public void f() {
GWT.log("Something went wrong: " + arguments(0));
}
});
Which version of android? is the app embedded in a cordova container?
Android 4.1, no the app is pure html
it works in the Chrome browser but not in the native Browser which has a lower webkit version.
@manolo Here is a posible solution: http://ghinda.net/jpeg-blob-ajax-android/
It seems a different solution since their problem is to send a Blob instead of a FormData in our case. Anyway this is not a gQuery problem but a chrome bug. I leave this opened so as you can go with a solution using an ArrayBuffer instead of using a FormData. I think converting the file content into an arraybuffer, you could send using gQuery.ajax. If you dont get a solution I'll try to spend sometime when I have a while.