File Transfer
This plugin allows you to upload and download files.
Cordovaの問題で困っていますか?

本格的なプロジェクトを構築している場合、トラブルシューティングに時間を費やす余裕はありません。Ionicのエキスパートが、保守、サポート、統合に関する公式サポートを提供しています。
インストール
Ionic Native Enterprise はIonic Teamが完全にサポートしメンテナンスしているプラグインを利用できます。 詳しくみる か、 エンタープライズプラグインに興味があれば 連絡ください
サポートしているプラットフォーム
- Amazon Fire OS
- Android
- Browser
- iOS
- Ubuntu
- Windows
- Windows Phone
利用方法
React
Angular
import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer/ngx';
import { File } from '@ionic-native/file';
constructor(private transfer: FileTransfer, private file: File) { }
...
const fileTransfer: FileTransferObject = this.transfer.create();
// Upload a file:
fileTransfer.upload(..).then(..).catch(..);
// Download a file:
fileTransfer.download(..).then(..).catch(..);
// Abort active transfer:
fileTransfer.abort();
// full example
upload() {
let options: FileUploadOptions = {
fileKey: 'file',
fileName: 'name.jpg',
headers: {}
.....
}
fileTransfer.upload('<file path>', '<api endpoint>', options)
.then((data) => {
// success
}, (err) => {
// error
})
}
download() {
const url = 'http://www.example.com/file.pdf';
fileTransfer.download(url, this.file.dataDirectory + 'file.pdf').then((entry) => {
console.log('download complete: ' + entry.toURL());
}, (error) => {
// handle error
});
}
To store files in a different/publicly accessible directory, please refer to the following link https://github.com/apache/cordova-plugin-file#where-to-store-files