DEV Community

Discussion on: CKEditor Image upload with Firebase and React

Collapse
 
devalo profile image
Stephan Bakkelund Valois

Hi, very nice article.
I just have a question.

Say the user adds an image, but regret the action and remove it from the editor.
The image will be uploaded to storage either way. How can we revert this action / delete the unused image from storage? or else, we might run into the problem of which we fill up our storage with unused images :p

Collapse
 
devalo profile image
Stephan Bakkelund Valois

I made a working solution to this. I'm pushing the file.name from your module into a root array, and taking substrings from the editor.getData() which only consists of image names. On create, I check both these arrays up against each other, and delete the images from storage that haven't been used.

This way, all the images will be temporarily until the user clicks save.
One edge case if if the user leaves the editor before the save is pressed. This also needs to be handled by deleting all images that has been uploaded temporarily.

Collapse
 
dhirajverma_in profile image
Dhiraj Verma

Hi Stephan. could you please tell me file repo. or any git hub link for this. please.

Collapse
 
anildharni profile image
Anil Dharni

Hi Stephan, I am stuck here. Could you please tell me how you achieved this using a code snippet?
Thank You.