I know that once in the Firebase console, one can use the "Import" function and upload a .json file with the required data.
In my case, I have a web page, which contains only the .json data. I want to download this web page and upload the data to Firebase. The upload process could be from a stand-alone computer application or from a JavaScript web page.
The idea is to let the owner of the data import the files into Firebase without any contact with Firebase's console.
Is such thing achievable? If yes, I would appreciate any pointers given.
The Firebase CLI can be used to manipulate data for a Firebase project.
Install it with Node/NPM:
npm install -g firebase-tools
Sign in with your Google account:
firebase login
Select your Firebase project for the CLI to use:
firebase use --add
Finally, import your JSON files:
firebase database:set /dataDestination ./data.json
database:set will replace all data at the specified location (/dataDestination above). If you would rather push data to a list instead, use database:push.
You should be able to implement this programmatically through Bash or whatever scripting language you prefer that can access shell commands.
A more comprehensive guide and reference for the CLI can be found here: https://firebase.google.com/docs/cli/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With