0

I'm having a problem saving large JSON ( containing lots of images as base64 that i fetch from firebase ) . The string length (I save it with JSON.stringify ) is about 13,000,000. While a json size 1,000,000 does save. I Tried AsyncStorage to discover it has a 6 MB limit on android. Then I switched to sqlite. In both cases im getting a NULL when trying to pull the data out of the 13,000,000 length json. Anyone can tell me what am i doing wrong? is there an alternative to what im doing?

  • is there any particular reason you're storing the images in a database? This is generally not good practice. Why not store them somewhere such as cloudinary or digital ocean spaces and load them only when they are needed? You can then store an array of links to the images in JSON wherever you want. – Joshua Underwood Nov 10 '17 at 17:25

1 Answers1

1

As @Joshua suggested, avoid saving base64 images to a database. You can save them to an S3 bucket, cloudinary CDN, or any number of 3rd party locations as he suggested. But you can also save them to the file system as binaries. You might find these articles helpful.

  1. If you're able to retrieve the images as blobs instead of base64 strings, then react-native-fetch-blob is probably your best bet.
  2. However, if you need to convert your base64 to a blob, then this SOF answer should be useful. Creating a Blob from a base64 string in JavaScript

Good luck!

Chris Geirman
  • 9,474
  • 5
  • 37
  • 70