How to use the @capacitor/core.FilesystemDirectory.Data function in @capacitor/core

To help you get started, we’ve selected a few @capacitor/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionic-team / capacitor / example / src / pages / filesystem / filesystem.ts View on Github external
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,
github ionic-team / capacitor / example / src / pages / camera / camera.ts View on Github external
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);
  }
github ionic-team / capacitor / example / src / pages / camera / camera.ts View on Github external
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);
  }
github ionic-team / capacitor / example / src / pages / filesystem / filesystem.ts View on Github external
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