uni.downloadFile({
url: url,
//url是服务器上面文件的地址
success: (res) => {
if (res.statusCode == 200) {
var tempFilePath=res.tempFilePath;
//现在已经保存到了临时文件夹,如果用uni.saveFile保存文件是以时间戳命名的,想移动文件到save文件夹并重新命名
var savepath='_doc/uniapp_save'
plus.io.resolveLocalFileSystemURL( tempFilePath, function( entry ) {
// 可通过fs进行文件操作
entry.copyTo( savepath,newname, function( entry ){
console.log("New Path: " + entry.fullPath);
}, function( e ){
console.log( e.message );
} );
}, function ( e ) {
console.log( "Request file system failed: " + e.message );
);
)},
fail(err) {
console.log(JSON.stringify(err))
}
});
![chenscript](https://img-cdn-tc.dcloud.net.cn/account/identicon/f52ac7d7abe334fb9526ebb27ea0a3be.png)
chenscript
- 发布:2019-02-25 14:53
- 更新:2019-02-25 14:53
- 阅读:1613
0 个回复