本文整理匯總了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});
});