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

Client does not support tempfile when it should #56

Closed burlesona closed 6 years ago

burlesona commented 6 years ago

I tried the following:

@uc = Uploadcare::Api.new({ ...settings... })
file = params[:file][:tempfile] # this returns a tempfile object
@uc.upload(file)

This blows up with the following error:

Expected `object` to be an Uploadcare::Api::File, an Array or a valid URL string, received: `#<File:0x00007faef4915320>`
uploadcare-ruby-2.1.2/lib/uploadcare/api/uploading_api.rb:13:in `upload'

The error is actually here: https://github.com/uploadcare/uploadcare-ruby/blob/e02b825787c95c7fa975dffd33dcba8e8b085178/lib/uploadcare/api/uploading_api.rb#L8

A tempfile is a file but not of class File so your case equality check fails. Tempfiles should be allowed.

burlesona commented 6 years ago

Fixed in https://github.com/uploadcare/uploadcare-ruby/pull/57

vizvamitra commented 6 years ago

Fixed in #59