Class: Ghee::API::Downloads::Proxy
- Inherits:
-
ResourceProxy
- Object
- ResourceProxy
- Ghee::API::Downloads::Proxy
- Defined in:
- lib/ghee/api/downloads.rb
Instance Attribute Summary
Attributes inherited from ResourceProxy
#connection, #current_page, #id, #pagination, #params, #path_prefix, #total
Instance Method Summary collapse
-
#create(file_path, description = "") ⇒ Object
Creates .
-
#destroy ⇒ Object
Destroys .
Methods inherited from ResourceProxy
accept_header, #all, #all_parallel, #build_prefix, #initialize, #method_missing, #paginate, #raw, #subject
Methods included from CUD
Constructor Details
This class inherits a constructor from Ghee::ResourceProxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ghee::ResourceProxy
Instance Method Details
#create(file_path, description = "") ⇒ Object
Creates
return json
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ghee/api/downloads.rb', line 10 def create(file_path, description="") params = { :name => File.basename(file_path), :size => File.size(file_path), :description => description } download = connection.post(path_prefix, params).body s3 = Faraday.new(:url => download["s3_url"]) do |builder| builder.request :multipart builder.request :url_encoded builder.adapter :net_http end upload = { :key => download["path"], :acl => download["acl"], :success_action_status => 201, :Filename => download["name"], :AWSAccessKeyId => download["accesskeyid"], :Policy => download["policy"], :Signature => download["signature"], :"Content-Type" => download["mime_type"], :file => Faraday::UploadIO.new(file_path, download["mime_type"]) } s3.post("/",upload).status == 201 return download end |
#destroy ⇒ Object
Destroys
return boolean
42 43 44 |
# File 'lib/ghee/api/downloads.rb', line 42 def destroy connection.delete(path_prefix).status == 204 end |