简体   繁体   中英

Ionic Save large file @Capacitor/filesystem - Out of memory error

I try to store multiple files in the file storage by using the @Capacitor/filesystem Plugin.

On large files I'm facing the following error - testet on my One Plus Pro 8 (Android 12):

W/System.err: java.lang.OutOfMemoryError: Failed to allocate a 150994952 byte allocation with 25165824 free bytes and 140MB until OOM, target footprint 280973616, growth limit 402653184

Code for saving the files:

Filesystem.writeFile({
        path,
        data: file.base64,
        directory: Directory.Data,
        recursive: true
      })

Project configuration:

**Ionic**:

   Ionic CLI                     : 6.19.0 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 6.0.8
   @angular-devkit/build-angular : 13.0.4
   @angular-devkit/schematics    : 13.0.4
   @angular/cli                  : 13.0.4
   @ionic/angular-toolkit        : 5.0.3

**Capacitor**:

   Capacitor CLI      : 3.4.1
   @capacitor/android : 3.4.1
   @capacitor/core    : 3.4.1
   @capacitor/ios     : not installed

**Utility**:

   cordova-res : not installed globally
   native-run  : 1.5.0

Saving large files is currently not supported (see https://github.com/ionic-team/capacitor/issues/984 ).

The Capacitor team has communicated on Discord that there are plans to add support with Capacitor 4.

I found the following package wich solved my problem:

Capacitor-blob-writer

It splits the file into multiple parts if it's to low.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM