Closed anuj9196 closed 7 years ago
Can you provide a reproduction of this?
Sorry, I think I couldn't understand what you are asking for. Can you be a little clear ?
Meanwhile, I can elaborate my question more.
I have added added behaviour into my table
$this->addBehavior('Josegonzalez/Upload.Upload', [
'video_file' => [
'path' => 'webroot{DS}files{DS}{model}{DS}{field}{DS}{microtime}{DS}',
'fields' => [
'dir' => 'dir', // defaults to `dir`
],
],
]);
Now, Whenever I create a new record, video is uploaded with every newEntity()
.
After sometime that record has to be deleted and user triggers delete()
to delete that record.
The record is being deleted from database but associated video is still there in the filesystem which is of no use now
I think there should be option to auto delete file on delete()
From the docs, you can set keepFilesOnDelete
to false. If you are generating any extra files, you'll need to use the deleteCallback
option as well.
$this->addBehavior('Josegonzalez/Upload.Upload', [
'video_file' => [
'path' => 'webroot{DS}files{DS}{model}{DS}{field}{DS}{microtime}{DS}',
'fields' => [
'dir' => 'dir', // defaults to `dir`
],
'keepFilesOnDelete' => false,
],
]);
added keepFilesOnDeleted => false
, still files are not deleting
Ooh, this could be related to #410 due to your use of microtime
in your path. As the path to your file will change every microsecond.
But what if path is saved to database, once path is generated you can take entity and path record from database before deletion is triggered and delete the file.
That's what the suggestion was in #409 and #410. I guess you'll need to wait for the pull request to be merged 😄
3.7.0 is out and contains the fix.
When record is deleting from database, the file is not deleting,
File should be deleted whenever record is deleted from database