Class: Harborapp::Upload
- Inherits:
-
Object
- Object
- Harborapp::Upload
- Includes:
- ApiModel
- Defined in:
- lib/harborapp/upload.rb
Instance Attribute Summary collapse
-
#curl_params ⇒ Object
Returns the value of attribute curl_params.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#key ⇒ Object
Returns the value of attribute key.
-
#s3_folder ⇒ Object
Returns the value of attribute s3_folder.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from ApiModel
#attrs, #errors, #errors=, included, #initialize, #new_record?, #populate, #success?
Instance Attribute Details
#curl_params ⇒ Object
Returns the value of attribute curl_params.
7 8 9 |
# File 'lib/harborapp/upload.rb', line 7 def curl_params @curl_params end |
#file_path ⇒ Object
Returns the value of attribute file_path.
7 8 9 |
# File 'lib/harborapp/upload.rb', line 7 def file_path @file_path end |
#key ⇒ Object
Returns the value of attribute key.
7 8 9 |
# File 'lib/harborapp/upload.rb', line 7 def key @key end |
#s3_folder ⇒ Object
Returns the value of attribute s3_folder.
7 8 9 |
# File 'lib/harborapp/upload.rb', line 7 def s3_folder @s3_folder end |
Class Method Details
.get_curl_params(file) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/harborapp/upload.rb', line 9 def self.get_curl_params file params = (file ? {:file => file} : {} ) upload = Harborapp::Api.request :post, "/uploads/curl", params upload.file_path = file upload.key = upload.s3_folder + "/" + SecureRandom.hex(6) + "-" + File.basename(file) upload end |
Instance Method Details
#deliver ⇒ Object
17 18 19 |
# File 'lib/harborapp/upload.rb', line 17 def deliver `curl https://s3.amazonaws.com/harborapp -F AWSAccessKeyId="#{curl_params["AWSAccessKeyId"]}" -F acl="public-read" -F key="#{key}" -F "content-type=#{curl_params["content-type"]}" -F "x-amz-security-token=#{curl_params["x-amz-security-token"]}" -F success_action_status="200" -F policy="#{curl_params["policy"]}" -F signature="#{curl_params["signature"]}" -F file=@"#{file_path}"` end |