Class: Cloudkey::File
Instance Method Summary collapse
Methods inherited from Client
Constructor Details
This class inherits a constructor from Cloudkey::Client
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Cloudkey::Client
Instance Method Details
#upload_file(path, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cloudkey/file.rb', line 3 def upload_file path, &block raise "File not found" unless ::File.exists? path curl(fetch_upload_url) do |c| c.multipart_form_post = true c.headers = false c.follow_location = true if block_given? c.on_progress do |dl_total, dl_now, ul_total, ul_now| block.call(ul_now, ul_total) if ul_total > 0.0 true end end c.http_post Curl::PostField.file("file", path) JSON.parse c.body_str end end |