[Files-Module] - How can you force delete a file (skip trash and remove the resource)
Created 6 years ago by edster

I have been trying to figure out how to delete a file from files module and resource, I know I can delete the file with Storage:: but I know there is a way to do it from the files module.

piterden  —  6 years ago Best Answer

Storage:: is the bad practice. Use repositories FileRepositoryInterface $files->forceDelete()

edster  —  6 years ago

Ah you do it through the repository, thanks @piterden!

ryanthompson  —  6 years ago

@edster you can technically do it with the model as well.

edster  —  6 years ago

Thanks @ryanthompson, so do $model->forceDelete() and that does the same?

What if I want to do this from a related stream/model.

I have a documents stream with a related file, (1-1) when I delete the document record, I want cascade and force delete the resource.