-
Notifications
You must be signed in to change notification settings - Fork 84
How to delete created images? #31
Comments
StorageManager::adapter($data['PdfFile']['adapter'])->delete($data['PdfFile']['path']); Calls the adapter directly - you have to make sure you build the correct path. If you used the same way to store images you won't even have any versions. You have to use the ImageStorage model. NOT the adapter directly. The adapter is a simple read/write Interface, it does not do the image processing magic, it just stores them. The model triggers events, look at the ImageStorage model and check Event/ImageProcessingListeiner.php for the actual implementation of image processing and deleting. The readme.md also says to look at ImageProcessingListeiner.php and that you should use the model for storing images. Read the "Image Versioning" section of the readme.md. If you extend or directly use the FileStorage model you don't even have to care of writing all the code yourself that is i the upper section of the readme.md, the model will do all the checking. |
Closing this now because no additional feedback was provided. |
Hi I am trying to delete as well with my versioning, In my ProductImagesTable I extends ImageStorageTable This is where I have my upload method based on your tutorial. I tried to create a delete method that removes the FileStorage row hoping the ImageStorageTable would run the ImageProcessingListener to listen for the delete which would remove the files like the upload did but that didn't work. Can you offer some advice thank you. |
I don't know how to unit test but I made a stackoverflow and detailing my enviroment I hope this helps. |
@artnos Please read about deleting data in CakePHP: http://book.cakephp.org/3.0/en/orm/deleting-data.html |
ugh, thank you I changed my delete to, it works now I knew about deleting this way i dont know why i choose the other way. |
In the instructions you write that one should use
to delete the file created before.
I am creating multiple sizes of my images. So I have one folder with a couple files. When I try to delete this folder as shown above ('path' points to the folder) I get a "Directory not empty" warning and nothing is deleted. Stepping through the code this is not surprising as the images itself are never removed.
How do I remove all images including the folder using your code? I could not find a suitable method or the parameters to clean up properly.
Thank you for any hints!
The text was updated successfully, but these errors were encountered: