fris-fruitig/react-firebase-file-uploader

how to delete image from storage ?

Closed this issue · 1 comments

how to delete image from storage ?
sprmn commented

You can find more on that subject here.

The onUploadSuccess function will be called with the filename of the uploaded file. Together with the storageRef you can obtain a reference to the file: storageRef.child(filename). Calling delete() on this wille delete the image from storage, if permissions are setup correctly.

You could do that for example in the onUploadStart function:

...
onUploadStart={() => {
  storageRef.child(this.state.filename).delete(); // do not forget to catch errors
  this.setState({ progress: 0 });
}}
...