ebe*_*ren 3 native download ionic4 cordova-native-file
我为需要文件的下载文件用户传输文件,在ionic v3中我也使用它,并且没有任何问题,但是现在在 ionic v4中,当我使用它时,出现了错误:类型'File不存在属性'dataDirectory' '
我的代码=> download.page.ts
download() {
const fileTransfer: FileTransferObject = this.transfer.create();
this.plt.ready().then(() => {
const url = 'http://www.test.com/file.mp3';
fileTransfer.download(url, this.file.dataDirectory + 'file.mp3').then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
// handle error
console.log('download EROR: ' + error);
});
});
}
Run Code Online (Sandbox Code Playgroud)
在下载页面和提供程序应用程序模块中导入的文件
Ionic 4在与Ionic 3的比较中使用了不同的导入路径。
import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer/ngx';
import { File } from '@ionic-native/file/ngx';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1532 次 |
| 最近记录: |