directlytos3 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,12 +14,12 @@ module Directlytos3
14
14
  options[:key] ||= ''
15
15
  options[:key].gsub!(/(\/)$/, '')
16
16
  options[:content_type] ||= MIME::Types.type_for("${filename}").to_s
17
- options[:redirect] ||= '/'
17
+ options[:redirect] ||= nil
18
18
  options[:acl] ||= 'public-read'
19
19
  options[:expiration_date] ||= 10.hours.from_now.utc.xmlschema
20
20
  options[:max_filesize] ||= 1.megabyte
21
21
  options[:randomize] ||= false
22
- options[:status] ||= 200
22
+ options[:status] ||= nil
23
23
  raise Directlytos3::Exceptions::NoBucketSpecified if !options[:bucket]
24
24
  raise Directlytos3::Exceptions::MissingAccessKey, "secret" if !options[:secret_key]
25
25
  raise Directlytos3::Exceptions::MissingAccessKey, "public" if !options[:access_key]
@@ -70,8 +70,8 @@ module Directlytos3
70
70
  concat hidden_field_tag('key', "#{options[:key]}#{'/' if !options[:key].blank?}#{Directlytos3.random_string if options[:randomize]}${filename}")
71
71
  concat hidden_field_tag('AWSAccessKeyId', "#{options[:access_key]}")
72
72
  concat hidden_field_tag('acl', "#{options[:acl]}")
73
- concat hidden_field_tag('success_action_redirect', "#{options[:redirect]}")
74
- # concat hidden_field_tag('success_action_status', "#{options[:status].to_s}")
73
+ concat hidden_field_tag('success_action_redirect', "#{options[:redirect]}") if options[:redirect]
74
+ concat hidden_field_tag('success_action_status', "#{options[:status].to_s}") if options[:status]
75
75
  concat hidden_field_tag('policy', "#{policy}")
76
76
  concat hidden_field_tag('signature', "#{signature}")
77
77
  concat hidden_field_tag('Content-Type', "#{options[:content_type]}")
@@ -18,11 +18,12 @@ module Directlytos3::S3
18
18
  {"bucket" => options[:bucket]},
19
19
  ["starts-with", "$key", options[:key]],
20
20
  {"acl" => options[:acl]},
21
- {"success_action_redirect" => options[:redirect]},
22
21
  ["starts-with", "$Content-Type", ''],
23
22
  ["content-length-range", 0, options[:max_filesize]]
24
23
  ]
25
24
  }
25
+ policy["conditions"] << {"success_action_redirect" => options[:redirect]} if options[:redirect]
26
+ policy["conditions"] << {"success_action_status" => options[:status].to_s} if options[:status]
26
27
  Base64.encode64(policy.to_json).gsub(/\n/,'')
27
28
  end
28
29
 
@@ -1,3 +1,3 @@
1
1
  module Directlytos3
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: directlytos3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70355887225840 !ruby/object:Gem::Requirement
16
+ requirement: &70171899550120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70355887225840
24
+ version_requirements: *70171899550120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: actionpack
27
- requirement: &70355887225340 !ruby/object:Gem::Requirement
27
+ requirement: &70171899549620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70355887225340
35
+ version_requirements: *70171899549620
36
36
  description: A rails helper to create an S3 upload form
37
37
  email:
38
38
  - scott@tesoriere.com