Class: S3Direct::UploadRequest
- Inherits:
-
Object
- Object
- S3Direct::UploadRequest
- Defined in:
- lib/s3direct/upload_request.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #attachment_filename ⇒ Object
-
#initialize(path, sanitized_filename, options = {}) ⇒ UploadRequest
constructor
A new instance of UploadRequest.
- #key ⇒ Object
- #max_upload_size ⇒ Object
- #s3_acl ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(path, sanitized_filename, options = {}) ⇒ UploadRequest
Returns a new instance of UploadRequest.
5 6 7 8 9 |
# File 'lib/s3direct/upload_request.rb', line 5 def initialize(path, sanitized_filename, = {}) @path = path @filename = sanitized_filename @options = end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
3 4 5 |
# File 'lib/s3direct/upload_request.rb', line 3 def filename @filename end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/s3direct/upload_request.rb', line 3 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/s3direct/upload_request.rb', line 3 def path @path end |
Instance Method Details
#attachment_filename ⇒ Object
34 35 36 |
# File 'lib/s3direct/upload_request.rb', line 34 def [:attachment_filename].presence end |
#key ⇒ Object
11 12 13 |
# File 'lib/s3direct/upload_request.rb', line 11 def key ::File.join(@path, @filename) end |
#max_upload_size ⇒ Object
42 43 44 |
# File 'lib/s3direct/upload_request.rb', line 42 def max_upload_size .fetch(:max_upload_size, config.max_upload_size) end |
#s3_acl ⇒ Object
38 39 40 |
# File 'lib/s3direct/upload_request.rb', line 38 def s3_acl .fetch(:acl, config.default_acl) end |
#to_json ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/s3direct/upload_request.rb', line 15 def to_json data = { url: config.bucket_url, filename: @filename, key: key, policy: s3_upload_policy_document, signature: s3_upload_signature, acl: s3_acl, success_action_status: "200", 'AWSAccessKeyId' => config.access_key } if data["Content-Disposition"] = %Q{attachment; filename="#{}"} end data.to_json end |