[ 
https://issues.apache.org/jira/browse/CB-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288905#comment-13288905
 ] 

Aurelien MERCIER commented on CB-861:
-------------------------------------

To be able to download a file from the community, I had to patch the download 
method since we are using oauth2.
I was wondering if you could add this modification for future Cordova releases?
Here are my fix:

cordova-1.7.0.js: (add params as a parameter of the download method)

FileTransfer.prototype.download = function(source, target, successCallback, 
errorCallback, params) {
   [...]
    exec(win, errorCallback, 'FileTransfer', 'download', [source, target, 
params]);
};

FileTransfer.java: 
Change the download method signature (add params) l 444 :
private PluginResult download(String source, String target, JSONObject params) {

add the following code after line 459: 
                connection.setRequestMethod("GET");

                // Handle headers
                try {
                    JSONObject headers = params.getJSONObject("headers");
                    for (Iterator iter = headers.keys(); iter.hasNext();)
                    {
                        String headerKey = iter.next().toString();
                        connection.setRequestProperty(headerKey, 
headers.getString(headerKey));
                    }
                } catch (JSONException e1) {
                    // No headers to be manipulated!
                }

By the way, this issue has not been solved by CB-78 since it was only for the 
upload method. So, if you could add that to the download method it would be 
great.

                
> Header support for PhoneGap's FileTransfer (download)
> -----------------------------------------------------
>
>                 Key: CB-861
>                 URL: https://issues.apache.org/jira/browse/CB-861
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: Android
>    Affects Versions: 1.7.0
>            Reporter: Aurelien MERCIER
>            Assignee: Joe Bowser
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to