简体   繁体   中英

How to download any file in PhoneGap using C# Webservice

I have no idea of how to download a file using a C# web service.

Please help me with the following C# code.

var fileTransfer = new FileTransfer();
var uri = encodeURI("http://some.server.com/File.docx");

fileTransfer.download(
    uri,
    downloadPath,
    function(entry) {
        console.log("Download compelete: " + entry.fullPath);
    },
    function(error) {
        console.log("Download error source " + error.source);
        console.log("Download error target " + error.target);
        console.log("Upload error code" + error.code);
    },
    false
);

But I don't want to give a URL like this. I want to download through Webservice. Is it possible?

Your question is very vague. I would suggest adding more details to try and get more answers. I can make the following recommendations for you to look into:

  1. Cordova File Plugin - This plugin allows your cordova app to mess with the files on the mobile's devices disk. Ie this lets you read and write files locally.
  2. Cordova File Transfer Plugin - This plugin allows you to connect to remote services (for example your C# service) and download files from them.
  3. Cordova White List Plugin - This is essential if you want to connect to external websites and services. Without this plugin and without defining your whitelist in config.xml you will not be able to connect to anything remotely.

I would also recommend looking at this and this for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM