Class: Vzaar::Uploaders::S3
- Inherits:
-
Struct
- Object
- Struct
- Vzaar::Uploaders::S3
- Defined in:
- lib/vzaar/uploaders/s3.rb
Constant Summary collapse
- SEND_TIMEOUT =
1800
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#signature ⇒ Object
Returns the value of attribute signature.
Instance Method Summary collapse
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path
3 4 5 |
# File 'lib/vzaar/uploaders/s3.rb', line 3 def path @path end |
#signature ⇒ Object
Returns the value of attribute signature
3 4 5 |
# File 'lib/vzaar/uploaders/s3.rb', line 3 def signature @signature end |
Instance Method Details
#upload ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vzaar/uploaders/s3.rb', line 6 def upload client = HTTPClient.new client.send_timeout = SEND_TIMEOUT begin file = File.open(path) res = client.post url, [ ['acl', signature.acl], ['bucket', signature.bucket], ['success_action_status', '201'], ['policy', signature.policy], ['AWSAccessKeyId', signature.access_key_id], ['signature', signature.signature], ['key', signature.key], ['file', file] ] ensure file.close if file end res.status_code == 201 end |
#url ⇒ Object
27 28 29 |
# File 'lib/vzaar/uploaders/s3.rb', line 27 def url "https://#{signature.bucket}.s3.amazonaws.com/" end |