FriendsOfCake / cakephp-upload

CakePHP: Handle file uploading sans ridiculous automagic
https://cakephp-upload.readthedocs.io/
MIT License
551 stars 255 forks source link

add callback for delete related file when delete a record #453

Closed saeideng closed 7 years ago

saeideng commented 7 years ago

we can generate other file (like thumb ) from primary file but when deleting a record we expected all of file (primary +related file) should delete from filesystem but just primary file deleted from filesystem ,and related file file still retain in filesystem there is not a callback for this now i looking for custom class like transformer

EDIT: a callback for this

ADmad commented 7 years ago

You can create a custom writer class which deletes related files when the primary file is deleted.

saeideng commented 7 years ago

callback is just for creating file constructFiles() used in beforeSave()

ADmad commented 7 years ago

I never said anything about a callback :) I said create a custom Writer class and override it's delete () method.

saeideng commented 7 years ago

I never said anything about a callback :)

i know :smiley: but callback is good choice and fast develop

some ting like

delete=>interface ....($name,$patch){//patch file in db
return [
         $patch+$name,
         $patch+'prefix_'+$name,
         $patch+$name+'_tumb_200_200.jpg',
]

}

ADmad commented 7 years ago

i looking for custom class like transformer

I was going by this statement. The writer class is that custom class :)

saeideng commented 7 years ago

thanks closing as related PR merged now