[Files-Module] - How can you force delete a file (skip trash and remove the resource)
Created 1 year 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  —  1 year ago Best Answer

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

edster  —  1 year ago

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

ryanthompson  —  1 year ago

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

edster  —  1 year 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.