Problem Deleting Image From Rails/Heroku App
I am having some problems deleting images from the media library from within my app. I try to delete using the public id, see below.
result = Cloudinary::Uploader.destroy(public_id)
This is the same id that is used with cl_image_tag to display the image after the upload, however the result['result'] returns not found.
The public id I am using is generated after upload by
preloaded = Cloudinary::PreloadedFile.new(params[:media][:image_id])
@media.image_id = preloaded.identifier
This code creates a id in the form of: v1406853798/media/nibbler_raise_wgkrrf.jpg
I have tried calling the delete with variations of this string from the full string, to
media/nibbler_raise_wgkrrf.jpg,
nibbler_raise_wgkrrf.jpg and,
nibbler_raise_wgkrrf.
but all of these produced the same result: Not found.
Just wondering what is going on here.
-
Hi John,
This 'v1406853798/media/nibbler_raise_wgkrrf.jpg' identifier actually includes 3 different components:
- The 'v1406853798' part is the version component
- The 'media/nibbler_raise_wgkrrf' part is the image's public ID
- The '.jpg' part is the format you tell Cloudinary to deliver your image in.
Therefore, when deleting an image, you should use only the middle part, for this case - it's 'media/nibbler_raise_wgkrrf'
0
Post is closed for comments.
Comments
1 comment