s3_cors_fileupload 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -8
- data/README.md +33 -12
- data/Rakefile +1 -22
- data/lib/generators/s3_cors_fileupload/install/templates/views/index.html.erb +1 -1
- data/lib/s3_cors_fileupload/rails/form_helper.rb +3 -1
- data/lib/s3_cors_fileupload/version.rb +1 -1
- data/s3_cors_fileupload.gemspec +1 -3
- metadata +5 -36
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
## 0.1.2
|
2
|
+
|
3
|
+
- Modified the FormHelper so that view helper method is named `s3_cors_fileupload_form_tag` (instead of `s3_cors_fileupload_form`) to maintain consistency with the rest of ActionView's view helpers.
|
4
|
+
- Improving usage documentation on the README to provide a more detailed explanation of what the gem provides.
|
5
|
+
|
6
|
+
## 0.1.1
|
7
|
+
|
8
|
+
- Fixed generator so that the [SourceFile model](https://github.com/fullbridge-batkins/s3_cors_fileupload/blob/master/lib/generators/s3_cors_fileupload/install/templates/source_file.rb) requires the aws-s3 gem properly.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -5,16 +5,10 @@ GEM
|
|
5
5
|
i18n (~> 0.6)
|
6
6
|
multi_json (~> 1.0)
|
7
7
|
diff-lcs (1.1.3)
|
8
|
-
|
8
|
+
gem-release (0.4.1)
|
9
9
|
i18n (0.6.1)
|
10
|
-
jeweler (1.8.4)
|
11
|
-
bundler (~> 1.0)
|
12
|
-
git (>= 1.2.5)
|
13
|
-
rake
|
14
|
-
rdoc
|
15
10
|
json (1.7.5)
|
16
11
|
multi_json (1.3.6)
|
17
|
-
rake (0.9.2.2)
|
18
12
|
rdoc (3.12)
|
19
13
|
json (~> 1.4)
|
20
14
|
rspec (2.11.0)
|
@@ -33,7 +27,7 @@ PLATFORMS
|
|
33
27
|
|
34
28
|
DEPENDENCIES
|
35
29
|
bundler
|
36
|
-
|
30
|
+
gem-release (~> 0.4)
|
37
31
|
rdoc (~> 3.12)
|
38
32
|
rspec (~> 2.11)
|
39
33
|
shoulda-matchers
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# S3CorsFileupload
|
2
2
|
|
3
|
-
A gem to allow for uploading of files to directly AWS-S3 via CORS via the
|
3
|
+
A gem to allow for uploading of files to directly AWS-S3 via [CORS](http://www.w3.org/TR/cors/) via the
|
4
4
|
[jQuery-File-Upload javascript](http://blueimp.github.com/jQuery-File-Upload/) for Rails 3.1 and greater.
|
5
5
|
|
6
6
|
## Installation
|
@@ -20,9 +20,9 @@ Now run the migration that was just generated:
|
|
20
20
|
|
21
21
|
bundle exec rake db:migrate
|
22
22
|
|
23
|
-
|
24
|
-
the fields with your AWS S3 credentials.
|
25
|
-
|
23
|
+
Also, as you may have noticed, a config file was generated at `config/amazon_s3.yml`. Edit this file and fill in
|
24
|
+
the fields with your AWS S3 credentials. If you don't want to commit your S3 account credentials to your
|
25
|
+
repository, you can make the config load from environment variables like so:
|
26
26
|
|
27
27
|
secret_access_key: <%= ENV['S3_SECRET_ACCESS_KEY'] %>
|
28
28
|
|
@@ -62,27 +62,48 @@ line like so:
|
|
62
62
|
|
63
63
|
<AllowedOrigin>*</AllowedOrigin>
|
64
64
|
|
65
|
-
Just be sure to change this before you put it into production, otherwise anybody
|
65
|
+
Just be sure to change this value to your server's domain before you put it into production, otherwise anybody
|
66
|
+
can upload to your bucket from any domain.
|
66
67
|
|
67
68
|
## Usage
|
68
69
|
|
69
70
|
Run your rails server
|
70
71
|
|
71
|
-
bundle exec rails
|
72
|
+
bundle exec rails server
|
72
73
|
|
73
74
|
Then navigate to `http://<server_root>/source_files` to get started. The files that `s3_cors_fileupload`'s install generator
|
74
|
-
provide you with are just a guide to get you started. I thought this would be helpful
|
75
|
+
provide you with are just a guide to get you started. I thought this would be helpful for others since it took me a while to
|
75
76
|
get the [jQuery-File-Upload javascript](http://blueimp.github.com/jQuery-File-Upload/) uploading directly to S3. I encourage
|
76
77
|
you to modify the controller, source files, and javascript as you see fit!
|
77
78
|
|
79
|
+
### What the gem provides for your Rails app
|
80
|
+
|
81
|
+
S3CorsFileupload will inject the javascripts and CSS (with the exception of [Twitter Bootstrap](http://twitter.github.com/bootstrap/))
|
82
|
+
styling necessary to render the UI version of the [jQuery-File-Upload javascript](http://blueimp.github.com/jQuery-File-Upload/)
|
83
|
+
into the asset pipeline of your Rails application. For more details on how Twitter Bootstrap is leveraged, see
|
84
|
+
[the Notes section below](#notes).
|
85
|
+
|
86
|
+
The gem also provides a view helper to your Rails app, `s3_cors_fileupload_form_tag`, which will produce a form that renders
|
87
|
+
the UI version of the [jQuery-File-Upload javascript](http://blueimp.github.com/jQuery-File-Upload/) when called.
|
88
|
+
This view helper accepts the following options:
|
89
|
+
|
90
|
+
* `:access_key_id` - The AWS Access Key ID of the owner of the bucket. Defaults to the `Config.access_key_id` (read from the `config/amazon_s3.yml` config file).
|
91
|
+
* `: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'`.
|
92
|
+
* `:max_file_size` - The max file size (in bytes) that you wish to allow to be uploaded. Defaults to `Config.max_file_size` (read from the `config/amazon_s3.yml` config file) or, if no value is set on the `config/amazon_s3.yml` file, defaults to `524288000` (500 MB)
|
93
|
+
* `:bucket` - The name of the bucket on S3 you wish for the files to be uploaded to. Defaults to `Config.bucket` (read from the `config/amazon_s3.yml` config file).
|
94
|
+
* Any other key creates standard HTML options for the form tag.
|
95
|
+
|
96
|
+
For an example of how to use the helper, see the file located at `app/views/s3_uploads/index.html.erb` that
|
97
|
+
the install generator produces.
|
98
|
+
|
78
99
|
## Notes
|
79
100
|
|
80
101
|
The UI version of the [jQuery-File-Upload javascript](http://blueimp.github.com/jQuery-File-Upload/)
|
81
|
-
javascript uses aspects of [Twitter
|
82
|
-
In
|
83
|
-
[BootstrapCDN](http://www.bootstrapcdn.com/)
|
84
|
-
your application, you may want look into using a gem such as
|
85
|
-
|
102
|
+
javascript uses aspects of the [Twitter Bootstrap](http://twitter.github.com/bootstrap/) CSS for styling purposes.
|
103
|
+
In the view file created at `s3_uploads/index.html.erb` by this gem's install generator, a copy of the Bootstrap CSS hosted on
|
104
|
+
[BootstrapCDN](http://www.bootstrapcdn.com/) is included via a `stylesheet_link_tag`. If you plan to use bootstrap in more
|
105
|
+
places throughout your application, you may want look into using a gem such as
|
106
|
+
[twitter-bootstrap-rails](https://github.com/seyhunak/twitter-bootstrap-rails), which allows you to inject
|
86
107
|
the stylesheets and javascripts from bootstrap into the asset pipeline.
|
87
108
|
|
88
109
|
## Contributing to S3CorsFileupload
|
data/Rakefile
CHANGED
@@ -4,33 +4,12 @@ require 'rubygems'
|
|
4
4
|
require 'bundler'
|
5
5
|
Bundler::GemHelper.install_tasks
|
6
6
|
|
7
|
-
require 'jeweler'
|
8
|
-
Jeweler::Tasks.new do |gem|
|
9
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
10
|
-
gem.name = "s3_cors_fileupload"
|
11
|
-
gem.homepage = "http://github.com/fullbridge-batkins/s3_cors_fileupload"
|
12
|
-
gem.license = "MIT"
|
13
|
-
gem.summary = %q{File uploads for Rails ~> 3.1 to AWS-S3 via CORS using the jQuery-File-Upload javascript}
|
14
|
-
gem.description = %q{File uploads for Rails ~> 3.1 to AWS-S3 via CORS using the jQuery-File-Upload javascript}
|
15
|
-
gem.email = ["benatkins@fullbridge.com"]
|
16
|
-
gem.authors = ["Ben Atkins"]
|
17
|
-
# dependencies defined in Gemfile
|
18
|
-
end
|
19
|
-
Jeweler::RubygemsDotOrgTasks.new
|
20
|
-
|
21
7
|
require 'rspec/core/rake_task'
|
22
8
|
RSpec::Core::RakeTask.new('spec')
|
23
9
|
|
24
10
|
# If you want to make this the default task
|
25
11
|
task :default => :spec
|
26
12
|
|
27
|
-
# require 'rake/testtask'
|
28
|
-
# Rake::TestTask.new(:test) do |test|
|
29
|
-
# test.libs << 'lib' << 'test'
|
30
|
-
# test.pattern = 'test/**/test_*.rb'
|
31
|
-
# test.verbose = true
|
32
|
-
# end
|
33
|
-
#
|
34
13
|
# require 'rcov/rcovtask'
|
35
14
|
# Rcov::RcovTask.new do |test|
|
36
15
|
# test.libs << 'test'
|
@@ -53,6 +32,6 @@ Rake::RDocTask.new do |rdoc|
|
|
53
32
|
end
|
54
33
|
|
55
34
|
desc "Open an irb session preloaded with this library"
|
56
|
-
task :
|
35
|
+
task :console do
|
57
36
|
sh "irb -I lib -r s3_cors_fileupload.rb"
|
58
37
|
end
|
@@ -15,7 +15,7 @@ module S3CorsFileupload
|
|
15
15
|
# Defaults to `Config.bucket` (read from the yaml config file).
|
16
16
|
#
|
17
17
|
# Any other key creates standard HTML options for the form tag.
|
18
|
-
def
|
18
|
+
def s3_cors_fileupload_form_tag(options = {}, &block)
|
19
19
|
policy_helper = PolicyHelper.new(options)
|
20
20
|
# initialize the hidden form fields
|
21
21
|
hidden_form_fields = {
|
@@ -32,6 +32,8 @@ module S3CorsFileupload
|
|
32
32
|
# return the form html
|
33
33
|
construct_form_html(hidden_form_fields, policy_helper.options[:bucket], _html_options, &block)
|
34
34
|
end
|
35
|
+
|
36
|
+
alias_method :s3_cors_fileupload_form, :s3_cors_fileupload_form_tag
|
35
37
|
|
36
38
|
private
|
37
39
|
|
data/s3_cors_fileupload.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ["benatkins@fullbridge.com"]
|
10
10
|
s.homepage = "http://github.com/fullbridge-batkins/s3_cors_fileupload"
|
11
11
|
s.summary = "File uploads for Rails ~> 3.1 to AWS-S3 via CORS using the jQuery-File-Upload script"
|
12
|
-
s.description = "A
|
12
|
+
s.description = "A gem for providing File uploads for Rails ~> 3.1 to AWS-S3 via CORS using the jQuery-File-Upload script"
|
13
13
|
s.licenses = ["MIT"]
|
14
14
|
|
15
15
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
@@ -21,8 +21,6 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_development_dependency('rake', [">= 0.8.7"])
|
23
23
|
s.add_development_dependency('bundler', [">= 0"])
|
24
|
-
s.add_development_dependency('rdoc', ["~> 3.12"])
|
25
|
-
s.add_development_dependency('jeweler', ["~> 1.8.4"])
|
26
24
|
|
27
25
|
s.files = `git ls-files`.split("\n")
|
28
26
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_cors_fileupload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -91,40 +91,8 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
-
-
|
95
|
-
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '3.12'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '3.12'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: jeweler
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 1.8.4
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ~>
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: 1.8.4
|
126
|
-
description: A Ruby gem for providing File uploads for Rails ~> 3.1 to AWS-S3 via
|
127
|
-
CORS using the jQuery-File-Upload script
|
94
|
+
description: A gem for providing File uploads for Rails ~> 3.1 to AWS-S3 via CORS
|
95
|
+
using the jQuery-File-Upload script
|
128
96
|
email:
|
129
97
|
- benatkins@fullbridge.com
|
130
98
|
executables: []
|
@@ -136,6 +104,7 @@ files:
|
|
136
104
|
- .document
|
137
105
|
- .gitignore
|
138
106
|
- .rspec
|
107
|
+
- CHANGELOG.md
|
139
108
|
- Gemfile
|
140
109
|
- Gemfile.lock
|
141
110
|
- LICENSE.txt
|