I have a firebase functions where I create a JSON:
var tempJSONObject = {
testing: "why are we testing",
anothertest:"constanttesting"
}
and I have a temp file:
const tempFilePath = path.join(os.tmpdir(), data.jokeid);
how do I save my JSON to this temporary file,so I can upload the file to firebase storage? I have to do this since when I pass the JSON directly to bucket.upload(),it asks me for a file path.
You don't need to save it to a file at all. You can simply stringify the object with JSON.stringify() , then upload that string to the bucket with File.createWriteStream() , writing the string value directly to the provided stream.
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.