Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async directoryTest() {
try {
await Plugins.Filesystem.writeFile({
path: 'text.txt',
data: "This is a test",
directory: FilesystemDirectory.Data,
encoding: FilesystemEncoding.UTF8
});
let stat = await Plugins.Filesystem.stat({
path: 'text.txt',
directory: FilesystemDirectory.Data
});
let data = await Plugins.Filesystem.readFile({
path: stat.uri
});
console.log('Stat 1', stat);
console.log(data);
/*
await Plugins.Filesystem.writeFile({
path: 'text.txt',
data: "This is a test",
directory: FilesystemDirectory.Data,
console.log('Got image back', image.path, image.webPath, image.format, image.exif);
const imageData = await Filesystem.readFile({
path: image.path
});
await Filesystem.writeFile({
path: 'cool-photo.jpg',
directory: FilesystemDirectory.Data,
data: imageData.data
});
let stat = await Plugins.Filesystem.stat({
path: 'cool-photo.jpg',
directory: FilesystemDirectory.Data
});
console.log(stat);
//this.image = this.sanitizer.bypassSecurityTrustResourceUrl("data:image/jpeg;base64," + imageData.data);
const imageUrl = image.webPath;
this.image = this.sanitizer.bypassSecurityTrustResourceUrl(imageUrl);
}
async takePictureFile() {
const image = await Plugins.Camera.getPhoto({
quality: 90,
allowEditing: true,
resultType: CameraResultType.Uri
})
console.log('Got image back', image.path, image.webPath, image.format, image.exif);
const imageData = await Filesystem.readFile({
path: image.path
});
await Filesystem.writeFile({
path: 'cool-photo.jpg',
directory: FilesystemDirectory.Data,
data: imageData.data
});
let stat = await Plugins.Filesystem.stat({
path: 'cool-photo.jpg',
directory: FilesystemDirectory.Data
});
console.log(stat);
//this.image = this.sanitizer.bypassSecurityTrustResourceUrl("data:image/jpeg;base64," + imageData.data);
const imageUrl = image.webPath;
this.image = this.sanitizer.bypassSecurityTrustResourceUrl(imageUrl);
}
async directoryTest() {
try {
await Plugins.Filesystem.writeFile({
path: 'text.txt',
data: "This is a test",
directory: FilesystemDirectory.Data,
encoding: FilesystemEncoding.UTF8
});
let stat = await Plugins.Filesystem.stat({
path: 'text.txt',
directory: FilesystemDirectory.Data
});
let data = await Plugins.Filesystem.readFile({
path: stat.uri
});
console.log('Stat 1', stat);
console.log(data);
/*
await Plugins.Filesystem.writeFile({
path: 'text.txt',
data: "This is a test",
directory: FilesystemDirectory.Data,
encoding: FilesystemEncoding.UTF8
});
stat = await Plugins.Filesystem.stat({
path: 'text.txt',
directory: FilesystemDirectory.Data