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

ArgumentError: wrong number of arguments #81

Closed frizbee closed 2 years ago

frizbee commented 2 years ago

When I follow the Usage section I'm getting number of errors, please advise

Steps

Then I'm getting the file:

@file = Uploadcare::File.file('FILE_ID_IN_YOUR_PROJECT')

After that I got file object, exactly as in example in Usage section. Next just below the object I can see 2 methods, one is store and one is delete file.

If I type @file.delete or @file.store none of those method are working.

For @file.delete I'm getting exact error I set as title wrong number of arguments. Ok, then I'm passing ID to the delete method: @file.delete(FILE_ID_IN_YOUR_PROJECT) and returning nil. File remain untouched, not deleted

According to the Usage section, I should be able to select file, then delete it with delete method.

Am I doing something wrong?

Version I'm using

gem 'uploadcare-ruby', git: 'git://github.com/uploadcare/uploadcare-ruby', branch: 'feature/1-new-entity-attrs'

I'm using this version because current 3.0.5 returning the error: NameError (uninitialized constant Uploadcare::Client::ApiStruct) I also tried with 3.1.0.pre.rc1 and getting same error while deleting the file as I described above.

CURL

I tried deleting file with REST API using curl, and got another error

path = '/files/?limit=1&stored=true' header = Uploadcare::Param::SecureAuthHeader.call(method: 'get', uri: path) curl -H 'Content-Type: application/json' -H 'Accept: application/vnd.uploadcare-v0.5+json' -H 'Date: #{header[:Date]}' -H 'Authorization: #{header[:Authorization]}' 'https://api.uploadcare.com#{path}'

Got error "{\"detail\":\"Invalid signature. Please check your secret key.\"}" I double checked secret key and generated new one, got same error.

Question is how come I can fetch files @file = Uploadcare::File.file('FILE_ID_IN_YOUR_PROJECT')or upload file with Uploadcare::Api.upload('https://placekitten.com/96/139')

dmitrijivanchenko commented 2 years ago

@frizbee, Hello! Thanks for reporting the bug. We have fixed this in v3.1.0 in main. Please, check this out

frizbee commented 2 years ago

Hey @rsedykh and @dmitrijivanchenko thanks for taking your time fixing this bugs, I was able to install new updated gem v3.1.0 and give it a try, however I still got error with deleting files. Does docs should be updated? thanks

Steps to reproduce:

require 'uploadcare'
@file = Uploadcare::File.file("FILE_ID_IN_YOUR_PROJECT")
=> {"datetime_removed"=>nil,
 "datetime_stored"=>"2021-10-13T11:04:11.676725Z",
 "datetime_uploaded"=>"2021-10-13T11:04:11.611810Z",
 "image_info"=>{"width"=>1280, "height"=>720, "format"=>"JPEG", "color_mode"=>"RGB", "geo_location"=>nil, "orientation"=>nil, "dpi"=>[72, 72], "datetime_original"=>nil, "sequence"=>false},
 "is_image"=>true,
 "is_ready"=>true,
 "mime_type"=>"image/jpeg",
 "original_file_url"=>"https://ucarecdn.com/FILE_ID_IN_YOUR_PROJECT/cupcake.jpeg",
 "original_filename"=>"cupcake.jpeg",
 "size"=>95646,
 "url"=>"https://api.uploadcare.com/files/FILE_ID_IN_YOUR_PROJECT/",
 "uuid"=>"xxxxxxxxxxxxxxxxxxxx",
 "source"=>nil}

 @file.delete
ArgumentError: wrong number of arguments (given 0, expected 1)
from /Users/frizbee/.rbenv/versions/2.7.2/gemsets/coachvantage_api/gems/hashie-4.1.0/lib/hashie/mash.rb:169:in `delete'

@file.delete('FILE_ID_IN_YOUR_PROJECT')
=> nil

File still exists :(

Expected behavior

@file.delete #deletes file. Returns updated metadata

Environment

dmitrijivanchenko commented 2 years ago

@frizbee, hi! Sorry for that desinformation. I just released v3.1.1. Can you, please, pull this one. Must be finaly fixed now

frizbee commented 2 years ago

Awesome @dmitrijivanchenko it works, thanks