Module: S3CorsFileupload::FormHelper
- Defined in:
- lib/s3_cors_fileupload/rails/form_helper.rb
Instance Method Summary collapse
-
#s3_cors_fileupload_form_tag(options = {}, &block) ⇒ Object
(also: #s3_cors_fileupload_form)
Options: :access_key_id The AWS Access Key ID of the owner of the bucket.
Instance Method Details
#s3_cors_fileupload_form_tag(options = {}, &block) ⇒ Object Also known as: s3_cors_fileupload_form
Options: :access_key_id The AWS Access Key ID of the owner of the bucket.
Defaults to the `Config.access_key_id` (read from the yaml config file).
:acl One of S3’s Canned Access Control Lists, must be one of:
'private', 'public-read', 'public-read-write', 'authenticated-read'.
Defaults to `'public-read'`.
:max_file_size The max file size (in bytes) that you wish to allow to be uploaded.
Defaults to `Config.max_file_size` or, if no value is set on the yaml file `524288000` (500 MB)
:bucket The name of the bucket on S3 you wish for the files to be uploaded to.
Defaults to `Config.bucket` (read from the yaml config file).
:secure Dictates whether the form action URL will be pointing to a secure URL or not.
Defaults to `true`.
Any other key creates standard HTML options for the form tag.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/s3_cors_fileupload/rails/form_helper.rb', line 21 def s3_cors_fileupload_form_tag( = {}, &block) policy_helper = PolicyHelper.new() # initialize the hidden form fields hidden_form_fields = { :key => '', 'Content-Type' => '', :AWSAccessKeyId => [:access_key_id] || Config.access_key_id, :acl => policy_helper.[:acl], :policy => policy_helper.policy_document, :signature => policy_helper.upload_signature, :success_action_status => '201' } # assume that all of the non-documented keys are = .reject { |key, val| [:access_key_id, :acl, :max_file_size, :bucket, :secure].include?(key) } # return the form html construct_form_html(hidden_form_fields, policy_helper.[:bucket], [:secure], , &block) end |