0

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Jim
  • 1,988
  • 6
  • 34
  • 68
  • This gives a number of solutions: https://stackoverflow.com/questions/37749647/firebasestorage-how-to-delete-directory/37757909 – jnpdx Jan 28 '21 at 00:51
  • those answers advocate the use of @google-cloud/storage with firebase functions, which is what i was trying to avoid, thanks though @jn_pdx – Jim Jan 28 '21 at 00:54

0 Answers0