uploadcare / uploadcare-ruby

Ruby API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
https://uploadcare.com
MIT License
39 stars 28 forks source link

`Uploadcare::File#delete` is not deleting the file. #118

Closed ricardoperezMTVH closed 1 year ago

ricardoperezMTVH commented 1 year ago

Describe the bug

Uploadcare::File#delete is not deleting the file.

Using the doc reference

file = Uploadcare::File.file("FILE_ID_IN_YOUR_PROJECT")
file.detele # return file json, but nothing happens.

Newly updated images

file = File.open(file_path)
uc_file = Uploadcare::Uploader.upload(file)
Uploadcare::File.delete(uc_file.uiid) # don't delete the file
uc.delete # also don't delete the file

Environment

kraft001 commented 1 year ago

@ricardoperezMTVH How do you check if the file isn't actually deleted? I tested the feature on the latest uploadcare-ruby version 4.3.1, and it works fine:

file_to_upload = File.open('test.png')
uc_file = Uploadcare::Uploader.upload(file_to_upload)

puts Uploadcare::File.info(uc_file.uuid).datetime_removed # => blank
Uploadcare::File.delete(uc_file.uuid)
puts Uploadcare::File.info(uc_file.uuid).datetime_removed # => 2023-03-20T18:48:29.416021Z

You can also run the test Rails project on your local env and try to click the "Delete" button there, it works well for me.

ricardoperezMTVH commented 1 year ago

@kraft001 I've tested that accessing directly the file on the CDN and listing the from the group. I haven't double checked that since the upgrade to the new version.

kraft001 commented 1 year ago

@ricardoperezMTVH Yes, the file is cached and the CDN copy can be accessed for some time after the main file is removed. If you want to remove the CDN cached copy as well, then it looks like a feature request

ricardoperezMTVH commented 1 year ago

@ricardoperezMTVH How do you check if the file isn't actually deleted? I tested the feature on the latest uploadcare-ruby version 4.3.1, and it works fine:

file_to_upload = File.open('test.png')
uc_file = Uploadcare::Uploader.upload(file_to_upload)

puts Uploadcare::File.info(uc_file.uuid).datetime_removed # => blank
Uploadcare::File.delete(uc_file.uuid)
puts Uploadcare::File.info(uc_file.uuid).datetime_removed # => 2023-03-20T18:48:29.416021Z

You can also run the test Rails project on your local env and try to click the "Delete" button there, it works well for me.

So, the image I'm deleting belongs to a group. To delele the image I use the delete Uploadcare::File.delete(image_identifier) but the image is still listed when I call Uploadcare::Group.group_info(group_identifier). (edit.: Ok, Now I can see when the image is listed in the group info the "datetime_removed" is now updated)

rsedykh commented 1 year ago

@ricardoperezMTVH hi. Right now we don't have cache invalidation feature that you can trigger via API. But we can set up a custom cache length for a project. Email us at help@uploadcare.com and mention this conversation to discuss it with my teammates.