Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
91 views
in Technique[技术] by (71.8m points)

javascript - How to use react-native-firebase to delete a whole directory in firebase Storage

Im trying to delete a folder in firebase storage, not just a file. im using react-native-firebase v5.

my directory structure looks something like this:

attachments
|__user-id
   |__session-id
      |__image1.png
      |__image2.png

my delete operation looks like:

firebase
  .storage()
  .ref(`archived-attachments/${uid}/${sessionId}/`)
  .delete()
  .then(() => {
     // do more stuff
  })
  .catch(err => dispatch({ type: types.UPDATE_FAIL, info: err.message }))

also tried:

 firebase
   .storage()
   .ref(`archived-attachments`)
   .child(uid)
   .child(sessionId)
   .delete()
   .then(() => {
      // do more stuff
   })
   .catch(err => dispatch({ type: types.UPDATE_FAIL, info: err.message }))

ive confirmed through logs that the uid & sessionId are correct and directly replicate the correct path to the folder i want deleted.

problem is an error is returned that says:

No object exists at the desired reference

Anyone have a solution for this? im trying to avoid creating a cloud function that uses @google-cloud/storage to do this.

question from:https://stackoverflow.com/questions/65929399/how-to-use-react-native-firebase-to-delete-a-whole-directory-in-firebase-storage

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...