Best way to save json data and files in react native? - react-native

I am developing a react-native application. I want it to get a json file online and print it as a list, showing the image and by clicking, showing the pdf. Here is my json :
[
{
"id":"1",
"nb_edit":0,
"nom":"Catalog 1",
"description":"test",
"apercu":"img\/1.png",
"pdf":"pdf\/1.pdf"
},
{
"id":"2",
"nb_edit":"0",
"nom":"Hi",
"description":"yes",
"apercu":"img\/2.png",
"pdf":"pdf\/2.pdf"
}
]
It actually works fine. But now, I want to add an offline mode. For this, I want to basically set a version variable in the application to 0, and check if the version on the website (version.txt) is the same. If yes, just load the json file saved in the phone (the png and pdf are saved too). If not, download the json, update the json saved locally, update the version variable, and then load the files from the phone.
Do you have an idea of how could I do? I thought about using redux-persist for the version, but will it work for the json, the images and the pdfs, and how?
Thanks for your help.

You can use :
Option1:
AsyncStorage is an unencrypted, asynchronous, persistent, key-value
storage system that is global to the app. It should be used instead of
LocalStorage.
https://reactnative.dev/docs/asyncstorage.html
Option2:
Local database
SQLite is an open-source SQL database that stores data to a text file
on a device. It supports all the relational database features. In
order to access this database, we don’t need to establish any kind of
connections for it like JDBC, ODBC.
react-native-sqlite-storage
https://www.npmjs.com/package/react-native-sqlite-storage

I would not try to save the file to the device. Instead of trying to save the file, I would save data to the device's storage by using AsyncStorage (If the file is not that big). If you go in this way, do not forget to stringify the object while saving the object to the storage.
You may use react-native-fs for saving files such as pdf, images.

Related

Search text from PDF files stored locally or in SQLite blob

I need to store PDF documents in either a local storage or SQLite (React-native iOS/Android). The app needs to work offline, so documents should be indexed and searchable for offline viewing.
Any ideas of how I can implement it? if I store a document in SQLite as blob, is there any plugin I can use to search. OR if is there any search engine library for react-native that can index the document as soon as PDF is uploaded.
Thanks in advance for your help/suggestions.

Backup data with Async Storage - React Native

I am creating a note-taking app.
I want to enable users to backup their data manually by clicking 'backup' button, which will create a db backup file.
Upon reinstalling the app, users should be able to restore their data by importing the db backup file.
Would this be possible? I've already seen posts about using Gdrive and ICloud, but this is automatic. I wish to export and import the db file of AsyncStorage manually. For example, expecting API something like AsyncStorage.createDbFile or equivalent.
Alternative would be to JSON.stringify all the data in AsyncStorage and put that on a txt file and export that, but I don't think this is a good idea (or is it perfectly fine to do this?).
Thank you!

Should I use AsyncStorage for large amounts of data?

We are wanting to implement an offline mode for our react-native application. We will be working with quite large amount of data (aprox. 40-50mb). It is an array of aprox. 16000 objects.
As far as I know, there are two ways to save this data.
Using AsyncStorage - android has a limit of 6mb, but I've read somewhere, that it can be increased.
Using json file - Downloading that data as json file using react-native-background-downloader and then using react-native-fs to save it and load it if the user has no connection to internet.
Personally I think that the second option is better, even though it requires permission to file storage.
Am I missing any other factors to consider? Are there any other options for offline access?
In the end opted out for usage of the json file as there is limit on android. On load of the application I take these data and load them into variable in mobX store. Which functions same as any variable.
I was afraid that mobile phones will have problem sorting across the 16000 objects in array, but there have been no reports of this thing going wrong so far. (In production for 4-5 months right now)
So basically when you hit "enable offline mode" I ask for the file storage permission and download the file using react-native-fs.
Then on the next startup of the application I just read the data off the JSON file.

Save pdf file loaded in iFrame to database after edit Oracle APEX

I am trying to save a PDF file that is loaded in an iFrame after sign it, i am using the (PSPDFKit standalone) in Oracle APEX 190200 version.
I need save the is database instead of download file.
How I can get file and save file in database through AJAX callback?
Screenshot:
You can use instance.exportPDF() to get the PDF as an ArrayBuffer. Then you can convert the ArrayBuffer to Blob and send it to the server. Hopefully, this should solve your issue.
I would suggest you to reach our support directly. We offer a blazing fast assistance and the questions are handled directly by the Web team: https://pspdfkit.com/support/request/.

How to store small to medium sets of data in iOS (for easy iCloud-sync)?

I have an iOS application that currently manages a small bunch of settings (via NSUserDefaults, I know how to sync these via iCloud) and some list data.
Let's say as an example I want to store a list of <color name / color / comment>. So I create a custom type, that is called ColorInfo. In my app I need to store multiple values of ColorInfo, I'd try and achieve that using an NSMutableArray or a database, but both are not easily synchronizable via the iCloud.
What ways to manage lists of data do you prefer in your iOS apps to meet the following two requirements?
You should be able to easily store the data persistently on the local phone.
You should be able to easily sync the data via the iCloud.
You want to use UIDocument its designed for local archiving and iCloud persistence.
Developer Doc
Do not use the key value storage. It is very.. weird.
I would make my own version of the key value storage by creating a local file and a remote file of the same name. To sync, you have to download the remote file and combine its contents with the local data. Write it to the file and upload the file.