Sending small objects from node.js server to Firebase Storage works great. If I have a big object, stringify fails. This is my current code.
const uploadJsonToFirebase = async (jsonObject, firebaseStorage, fullPath) => {
try {
const jsonString = JSON.stringify(jsonObject, null, 2);
const bucket = await firebaseStorage.bucket();
const file = bucket.file(fullPath);
const contents = jsonString;
await file.save(contents);
} catch (error) {
console.error("Error uploading JSON to Firebase:", error);
throw error;
}
};
module.exports = uploadJsonToFirebase;
And error for big files:
Error uploading JSON to Firebase: RangeError: Invalid string length at JSON.stringify ()
I've tried streaming, but could not figure the right flow. The Objects needs to be stored as .json files, as they will be consumed at a later time by other parts of the aplication.