Class: Tenon::S3DirectUpload
- Inherits:
-
Object
- Object
- Tenon::S3DirectUpload
- Includes:
- S3SwfUpload::Signature
- Defined in:
- app/models/tenon/s3_direct_upload.rb
Instance Attribute Summary collapse
-
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
-
#bucket ⇒ Object
Returns the value of attribute bucket.
-
#options ⇒ Object
Returns the value of attribute options.
-
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ S3DirectUpload
constructor
A new instance of S3DirectUpload.
- #post_params ⇒ Object
- #upload_url ⇒ Object
Methods included from S3SwfUpload::Signature
#assert, #b64_hmac_sha1, #binb2b64, #binb2hex, #core_hmac_sha1, #core_sha1, #hex_sha1, #rol, #safe_add, #self_test, #sha1_ft, #sha1_kt, #str2binb
Constructor Details
#initialize(opts = {}) ⇒ S3DirectUpload
Returns a new instance of S3DirectUpload.
7 8 9 10 11 12 13 14 |
# File 'app/models/tenon/s3_direct_upload.rb', line 7 def initialize(opts = {}) self. = .merge(opts.symbolize_keys) config = YAML.load_file([:config_file]) self.bucket = config[Rails.env]['bucket'] self.access_key_id = config[Rails.env]['access_key_id'] self.secret_access_key = config[Rails.env]['secret_access_key'] end |
Instance Attribute Details
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
5 6 7 |
# File 'app/models/tenon/s3_direct_upload.rb', line 5 def access_key_id @access_key_id end |
#bucket ⇒ Object
Returns the value of attribute bucket.
5 6 7 |
# File 'app/models/tenon/s3_direct_upload.rb', line 5 def bucket @bucket end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'app/models/tenon/s3_direct_upload.rb', line 5 def @options end |
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
5 6 7 |
# File 'app/models/tenon/s3_direct_upload.rb', line 5 def secret_access_key @secret_access_key end |
Instance Method Details
#post_params ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/tenon/s3_direct_upload.rb', line 16 def post_params { 'key' => "#{[:key]}/#{time}-${filename}", 'AWSAccessKeyId' => "#{access_key_id}", 'acl' => "#{[:acl]}", 'policy' => "#{policy}", 'signature' => "#{signature}", 'success_action_status' => '201', '__utma' => '1', '__utmb' => '1', '__utmc' => '1', '__utmz' => '1', 'auth_token' => '1' } end |
#upload_url ⇒ Object
32 33 34 |
# File 'app/models/tenon/s3_direct_upload.rb', line 32 def upload_url "http://#{bucket}.s3.amazonaws.com/" end |