Class: S3FileField::S3Uploader
- Inherits:
-
Object
- Object
- S3FileField::S3Uploader
- Defined in:
- lib/s3_file_field/s3_uploader.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #field_data_options ⇒ Object
- #field_options ⇒ Object
-
#initialize(original_options = {}) ⇒ S3Uploader
constructor
A new instance of S3Uploader.
Constructor Details
#initialize(original_options = {}) ⇒ S3Uploader
Returns a new instance of S3Uploader.
5 6 7 8 9 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 37 38 |
# File 'lib/s3_file_field/s3_uploader.rb', line 5 def initialize( = {}) = { access_key_id: S3FileField.config.access_key_id, secret_access_key: S3FileField.config.secret_access_key, bucket: S3FileField.config.bucket, acl: "public-read", expiration: 10.hours.from_now.utc.iso8601, max_file_size: 500.megabytes, conditions: [], key_starts_with: 'uploads/' } @key = [:key] = # Remove s3_file_field specific options from original options = .extract!(*.keys). reject { |k, v| v.nil? } = .merge() unless [:access_key_id] raise Error.new("Please configure access_key_id option.") end unless [:secret_access_key] raise Error.new("Please configure secret_access_key option.") end unless [:bucket] raise Error.new("Please configure bucket name.") end end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/s3_file_field/s3_uploader.rb', line 3 def end |
Instance Method Details
#field_data_options ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/s3_file_field/s3_uploader.rb', line 44 def { url: url, key: key, acl: [:acl], aws_access_key_id: [:access_key_id], policy: policy, signature: signature }.merge([:data] || {}) end |
#field_options ⇒ Object
40 41 42 |
# File 'lib/s3_file_field/s3_uploader.rb', line 40 def .merge(data: ) end |