本文整理汇总了TypeScript中@ionic-native/file.File.writeFile方法的典型用法代码示例。如果您正苦于以下问题:TypeScript File.writeFile方法的具体用法?TypeScript File.writeFile怎么用?TypeScript File.writeFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ionic-native/file.File
的用法示例。
在下文中一共展示了File.writeFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: writeFileFromBase64
// here is the method is used to write a file in storage
// https://www.c-sharpcorner.com/article/how-to-save-picture-to-specific-path-in-ionic-3-using-native-camera-plugin/
public writeFileFromBase64(base64Data: any, filePath: string, fileName?: string): void {
let contentType: any = this.getContentType(base64Data);
let dataBlob: Blob = this.base64toBlob(base64Data.split(',')[1], contentType);
// TODO dummy random name implementation
let newFileName: string = fileName ? fileName : Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)+'.jpeg';
this.file.writeFile(filePath, newFileName, dataBlob, contentType).then((success) => {
console.log('File Writed Successfully to location: ' + filePath + newFileName);
}).catch((err) => {
console.log('Error Occured While Writing File: '+ filePath + newFileName, err.message);
})
}
示例2: fixFileReader
const writeToFile = (path, filename, data: Blob | string) => {
fixFileReader()
return FILE.writeFile(path, filename, data)
}
示例3: Observable
return new Observable(observer => {
this.file.writeFile(this.file.dataDirectory, filePath, text)
.then((success) => observer.next(success))
.catch((error) => observer.error(error));
});
示例4:
promise = Promise.all(filePromises).then(() => {
// File read and parent folder created, now write the file.
const parentFolder = this.textUtils.concatenatePaths(destination, fileDir);
return this.file.writeFile(parentFolder, fileName, fileData, {replace: true});
});