Class: Ghee::API::Repos::Downloads::Proxy
- Inherits:
-
ResourceProxy
- Object
- ResourceProxy
- Ghee::API::Repos::Downloads::Proxy
- Defined in:
- lib/ghee/api/downloads.rb
Instance Attribute Summary
Attributes inherited from ResourceProxy
#connection, #current_page, #pagination, #params, #path_prefix, #total
Instance Method Summary collapse
-
#create(file_path, description = "") ⇒ Object
Creates .
-
#destroy ⇒ Object
Destroys .
Methods inherited from ResourceProxy
#all, #initialize, #method_missing, #paginate, #subject
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
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 37 |
# File 'lib/ghee/api/downloads.rb', line 11 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
43 44 45 |
# File 'lib/ghee/api/downloads.rb', line 43 def destroy connection.delete(path_prefix).status == 204 end |