'How to add .txt file to firebase storage when cloud function is triggered?
I have a cloud function which checks if update field is true in {user} document field.
I have text file in my functions folder, path: functions/test.txt
When the update becomes true, a new collection is created with description "update triggered". How do I upload my test.txt file to firebase storage only when the update:true is triggered?
exports.statusUpdate = functions.firestore.document("test/{user}")
.onUpdate((change, context) => {
let user = context.params.user
const newValue = change.after.data();
const previousValue = change.before.data();
if(newValue.update == true) {
db.collection('true').add({description: `update triggered`})
//upload the test.txt file in firebase storage
} })
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

