本文整理汇总了TypeScript中@ionic-native/file.File.resolveLocalFilesystemUrl方法的典型用法代码示例。如果您正苦于以下问题:TypeScript File.resolveLocalFilesystemUrl方法的具体用法?TypeScript File.resolveLocalFilesystemUrl怎么用?TypeScript File.resolveLocalFilesystemUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ionic-native/file.File
的用法示例。
在下文中一共展示了File.resolveLocalFilesystemUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: uploadPhoto
async uploadPhoto(imageFileUri: any): Promise<void> {
this.myPhoto = imageFileUri;
this.error = null;
this.loading = this.loadingCtrl.create({
content: 'Uploading...'
});
await this.loading.present();
const fileTransfer: FileTransferObject = this.transfer.create();
const fileEntry = await this.file.resolveLocalFilesystemUrl(imageFileUri);
const options: FileUploadOptions = {
fileKey: 'file',
fileName: fileEntry.name,
headers: {}
};
try {
const result = await fileTransfer.upload(imageFileUri, 'http://192.168.178.84:8080/upload', options);
console.log(result.bytesSent);
console.log(result.responseCode);
this.showToast(true);
}
catch (e) {
console.log(e);
this.showToast(false);
}
finally {
this.loading.dismiss();
}
}
示例2:
getFileMimeType: (url) => Bluebird.resolve(FILE.resolveLocalFilesystemUrl(url))
.then((file: FileEntry) => new Bluebird<any>((resolve, reject) => file.file(resolve, reject))
.then((file) => file.type)),