I developed an app using MGWT and GwtPhoneGap and I used rpc for server communication. I want to download a file from server to my client device(iOs/android).is this possible? if so what I need to do to achieve my goal?. I'm not getting great support from MGWT forums. Please tell me the way to do it.
thanks in Advance
I put some effort on my question, I've done like this. but still not succeeded. please go through my code.
public final native String download(String serverUrl,String filepath,Callback callback)
/*-{
return this.download(serverUrl, filePath, function(result) {
callback.Callback::o:onSuccess(Result;);)(result);
}, function(error) {
callback.Callback::o:onError(Error;);)(error);
});
}-*/;
If the file is a simple file (A PDF for exemple) Just put a link to the file URL, the mobile navigator will download the file to the phone. If the file is generated, you must create a servlet for doing the download :
In GWT for a Post Request, you can use th FormPanel which will send the request to an hidden iframe.
Or you can put a real form.
But with PhoneGap, you can use the File API, but you must ask to the user where write the file in his phone. You can download the file content via a RPC request if you want, and write to the file.
In my case I just wrote a servlet which will provide the file.
From then on you have two choices:
For POST requests use a RequestBuilder (not hidden forms !), then write the response to a new window using JSNI.