logo头像
Snippet 博客主题

ionic 文件上传下载 cordova-plugin-file-transfer

本文于536天之前发表,文中内容可能已经过时。

文件上传下载 cordova-plugin-file-transfer

下载地址
git

下载

1
2
3
4
5
6
7
download(
source: string,
target: string,
successCallback: (fileEntry: FileEntry) => void,
errorCallback: (error: FileTransferError) => void,
trustAllHosts?: boolean,
options?: FileDownloadOptions): void;

demo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var source = encodeURI(motion.videoUrl);
var target = "/storage/emulated/0//DCIM/camera/ED73463F498CF11D9F3834E18DAA1E10_motion_1507718040820.jpg" ;

var fileTransfer = new FileTransfer();
fileTransfer.download(source,target,
function(entry) {
console.log("download complete: " + entry.toURL());
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("download error code" + error.code);
},
false
,null
);
参数 类型 说明
source String 下载地址 url
target String 文件下载目标地址
successCallback Function 文件下载成功 Callback
errorCallback Function 文件下载失败 Callback
trustAllHosts boolean defaults to false. If set to true, it accepts all security certificates. Not recommended for production use. Supported on iOS.
options boolean currently only supports headers (such as Authorization (Basic Authentication), etc)

上传

支付宝打赏 微信打赏

打赏