s3_cors_fileupload 0.2.1 → 0.3.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/CHANGELOG.md +10 -3
- data/Gemfile +11 -9
- data/Gemfile.lock +86 -65
- data/README.md +8 -4
- data/lib/generators/s3_cors_fileupload/install/install_generator.rb +5 -2
- data/lib/generators/s3_cors_fileupload/install/templates/s3_uploads_controller.rb +3 -1
- data/lib/generators/s3_cors_fileupload/install/templates/source_file.rb +4 -3
- data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_download.html.erb +18 -7
- data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_upload.html.erb +4 -4
- data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_uploaded.html.erb +17 -6
- data/lib/generators/s3_cors_fileupload/install/templates/views/erb/index.html.erb +1 -1
- data/lib/generators/s3_cors_fileupload/install/templates/views/haml/_template_download.html.haml +14 -4
- data/lib/generators/s3_cors_fileupload/install/templates/views/haml/_template_upload.html.haml +5 -5
- data/lib/generators/s3_cors_fileupload/install/templates/views/haml/_template_uploaded.html.haml +12 -1
- data/lib/generators/s3_cors_fileupload/install/templates/views/haml/index.html.haml +1 -1
- data/lib/s3_cors_fileupload.rb +6 -0
- data/lib/s3_cors_fileupload/rails.rb +1 -1
- data/lib/s3_cors_fileupload/rails/form_helper.rb +15 -12
- data/lib/s3_cors_fileupload/version.rb +3 -3
- data/s3_cors_fileupload.gemspec +3 -4
- data/spec/dummy/Rakefile +0 -1
- data/spec/dummy/app/assets/javascripts/application.js +4 -3
- data/spec/dummy/app/assets/javascripts/s3_uploads.js +92 -0
- data/spec/dummy/app/assets/stylesheets/application.css +1 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -1
- data/spec/dummy/app/controllers/s3_uploads_controller.rb +56 -0
- data/spec/dummy/app/models/source_file.rb +54 -0
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/app/views/s3_uploads/_template_download.html.erb +43 -0
- data/spec/dummy/app/views/s3_uploads/_template_upload.html.erb +36 -0
- data/spec/dummy/app/views/s3_uploads/_template_uploaded.html.erb +41 -0
- data/spec/dummy/app/views/s3_uploads/index.html.erb +41 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/config/application.rb +2 -33
- data/spec/dummy/config/boot.rb +4 -9
- data/spec/dummy/config/environment.rb +2 -2
- data/spec/dummy/config/environments/development.rb +14 -19
- data/spec/dummy/config/environments/production.rb +40 -27
- data/spec/dummy/config/environments/test.rb +14 -12
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +6 -5
- data/spec/dummy/config/initializers/secret_token.rb +7 -2
- data/spec/dummy/config/initializers/session_store.rb +0 -5
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/spec/dummy/config/locales/en.yml +20 -2
- data/spec/dummy/config/routes.rb +27 -24
- data/spec/dummy/db/migrate/20131001201535_create_source_files.rb +14 -0
- data/spec/dummy/db/schema.rb +27 -0
- data/spec/dummy/public/404.html +43 -11
- data/spec/dummy/public/422.html +43 -11
- data/spec/dummy/public/500.html +43 -11
- data/spec/features/uploads_spec.rb +37 -0
- data/spec/lib/s3_cors_fileupload/rails/engine_spec.rb +8 -0
- data/spec/lib/s3_cors_fileupload/rails/form_helper_spec.rb +30 -0
- data/spec/lib/s3_cors_fileupload/rails/policy_helper_spec.rb +95 -0
- data/spec/s3_cors_fileupload_spec.rb +8 -4
- data/spec/spec_helper.rb +8 -8
- data/spec/support/dummy.pdf +0 -0
- data/vendor/assets/javascripts/s3_cors_fileupload/index.js +1 -0
- data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-image.js +111 -32
- data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-ui.js +24 -18
- data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-validate.js +7 -6
- data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload.js +22 -15
- data/vendor/assets/javascripts/s3_cors_fileupload/vendor/load-image-meta.js +137 -0
- data/vendor/assets/javascripts/s3_cors_fileupload/vendor/tmpl.js +8 -8
- data/vendor/assets/stylesheets/jquery.fileupload-ui.css.erb +2 -1
- metadata +56 -28
- data/spec/dummy/script/rails +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b847b99b1ab87ff28551afbc29835bae6d05ade
|
|
4
|
+
data.tar.gz: d9329093fdede0b711a306514b69304b85ad2b8e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5aec54483c76bf143514a86f90c0ba792838635b7e4744f3c71099d6116a179f201b879add769631f11ed45bf2ea8364930cb50df5223d6ec2d76bee4e0ec87
|
|
7
|
+
data.tar.gz: 63a8cc7ec0cd76e0d287e3b1f16bd5ddc9e2063170da7e953ea1856bbace1dcfb903076ba86390986a8dbd056985963c601f6b88a1a10a71b5632436b6ed73dd
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
## 0.3.0
|
|
2
|
-
|
|
1
|
+
## 0.3.0
|
|
2
|
+
|
|
3
|
+
- Rails 4 compatibility.
|
|
4
|
+
- Upgraded jQuery-File-Upload and corresponding JavaScript dependencies to most recent releases
|
|
5
|
+
(see [lib/s3\_cors\_fileupload/version.rb](https://github.com/fullbridge-batkins/s3_cors_fileupload/blob/master/lib/s3_cors_fileupload/version.rb) for the current version #'s)
|
|
6
|
+
- Updated to [Twitter Bootstrap](http://twitter.github.com/bootstrap/) 3.
|
|
7
|
+
- Added new `:secure` option that can be passed into the `FormHelper`'s `s3_cors_fileupload_form_tag` method to set the protocol to `http` or `https` (defaults to `https`).
|
|
8
|
+
- Removed dependency on [jquery-rails](https://github.com/rails/jquery-rails), since there are other valid solutions for including it to a Rails app.
|
|
3
9
|
- Added a lot more spec coverage.
|
|
4
10
|
|
|
5
11
|
## 0.2.1
|
|
6
12
|
|
|
7
13
|
- Adjusted FormHelper module so that the 'Add files...' button is a `span` tag instead of a `button` tag (fixes compatibility with FireFox)
|
|
8
|
-
- Upgraded jQuery-File-Upload and the other JavaScript files it is dependent upon to the most recent releases
|
|
14
|
+
- Upgraded jQuery-File-Upload and the other JavaScript files it is dependent upon to the most recent releases
|
|
15
|
+
(see [lib/s3\_cors\_fileupload/version.rb](https://github.com/fullbridge-batkins/s3_cors_fileupload/blob/v0.2.1/lib/s3_cors_fileupload/version.rb) for the current version #'s)
|
|
9
16
|
- Added new Process and Validation plugins from the jQuery-File-Upload package.
|
|
10
17
|
- Minor stability enhancements.
|
|
11
18
|
|
data/Gemfile
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
group :development do
|
|
4
|
-
gem 'rdoc', '~>
|
|
4
|
+
gem 'rdoc', '~> 4.0'
|
|
5
5
|
gem 'gem-release', '~> 0.6'
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
group :test do
|
|
9
|
-
gem 'rspec-rails', '~> 2.13'
|
|
10
|
-
gem 'shoulda-matchers', '~> 2.0'
|
|
11
|
-
gem 'generator_spec'
|
|
12
|
-
gem 'ffaker'
|
|
13
|
-
|
|
14
9
|
# dependencies for S3CorsFileUpload
|
|
15
|
-
gem 'rails', '~>
|
|
16
|
-
# gem 'jquery-rails' # would be necessary to do UI testing on the dummy app
|
|
17
|
-
gem 'sqlite3' # the database driver for rails
|
|
10
|
+
gem 'rails', '~> 4.0'
|
|
18
11
|
gem 'aws-s3'
|
|
12
|
+
gem 'sqlite3' # the database driver for rails
|
|
13
|
+
gem 'jquery-rails' # for including jQuery into the dummy app
|
|
14
|
+
|
|
15
|
+
gem 'rspec-rails', '~> 2.14'
|
|
16
|
+
gem 'shoulda-matchers', '~> 2.4'
|
|
17
|
+
gem 'generator_spec'
|
|
18
|
+
gem 'ffaker'
|
|
19
|
+
gem 'capybara'
|
|
20
|
+
gem 'poltergeist' # to use as JS driver for Capybara
|
|
19
21
|
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,86 +1,95 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: https://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
-
actionmailer (
|
|
5
|
-
actionpack (=
|
|
4
|
+
actionmailer (4.0.0)
|
|
5
|
+
actionpack (= 4.0.0)
|
|
6
6
|
mail (~> 2.5.3)
|
|
7
|
-
actionpack (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
builder (~> 3.0.0)
|
|
7
|
+
actionpack (4.0.0)
|
|
8
|
+
activesupport (= 4.0.0)
|
|
9
|
+
builder (~> 3.1.0)
|
|
11
10
|
erubis (~> 2.7.0)
|
|
12
|
-
|
|
13
|
-
rack (~>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
arel (3.0.2)
|
|
11
|
+
rack (~> 1.5.2)
|
|
12
|
+
rack-test (~> 0.6.2)
|
|
13
|
+
activemodel (4.0.0)
|
|
14
|
+
activesupport (= 4.0.0)
|
|
15
|
+
builder (~> 3.1.0)
|
|
16
|
+
activerecord (4.0.0)
|
|
17
|
+
activemodel (= 4.0.0)
|
|
18
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
|
19
|
+
activesupport (= 4.0.0)
|
|
20
|
+
arel (~> 4.0.0)
|
|
21
|
+
activerecord-deprecated_finders (1.0.3)
|
|
22
|
+
activesupport (4.0.0)
|
|
23
|
+
i18n (~> 0.6, >= 0.6.4)
|
|
24
|
+
minitest (~> 4.2)
|
|
25
|
+
multi_json (~> 1.3)
|
|
26
|
+
thread_safe (~> 0.1)
|
|
27
|
+
tzinfo (~> 0.3.37)
|
|
28
|
+
arel (4.0.0)
|
|
29
|
+
atomic (1.1.14)
|
|
32
30
|
aws-s3 (0.6.3)
|
|
33
31
|
builder
|
|
34
32
|
mime-types
|
|
35
33
|
xml-simple
|
|
36
|
-
builder (3.
|
|
34
|
+
builder (3.1.4)
|
|
35
|
+
capybara (2.1.0)
|
|
36
|
+
mime-types (>= 1.16)
|
|
37
|
+
nokogiri (>= 1.3.3)
|
|
38
|
+
rack (>= 1.0.0)
|
|
39
|
+
rack-test (>= 0.5.4)
|
|
40
|
+
xpath (~> 2.0)
|
|
41
|
+
cliver (0.2.2)
|
|
37
42
|
diff-lcs (1.2.4)
|
|
38
43
|
erubis (2.7.0)
|
|
39
|
-
ffaker (1.
|
|
44
|
+
ffaker (1.19.0)
|
|
40
45
|
gem-release (0.6.0)
|
|
41
46
|
generator_spec (0.9.0)
|
|
42
47
|
activerecord (>= 3.0, <= 4.0)
|
|
43
48
|
railties (>= 3.0, <= 4.0)
|
|
44
49
|
hike (1.2.3)
|
|
45
|
-
i18n (0.6.
|
|
46
|
-
|
|
50
|
+
i18n (0.6.5)
|
|
51
|
+
jquery-rails (3.0.4)
|
|
52
|
+
railties (>= 3.0, < 5.0)
|
|
53
|
+
thor (>= 0.14, < 2.0)
|
|
47
54
|
json (1.8.0)
|
|
48
|
-
mail (2.5.
|
|
49
|
-
i18n (>= 0.4.0)
|
|
55
|
+
mail (2.5.4)
|
|
50
56
|
mime-types (~> 1.16)
|
|
51
57
|
treetop (~> 1.4.8)
|
|
52
|
-
mime-types (1.
|
|
53
|
-
|
|
58
|
+
mime-types (1.25)
|
|
59
|
+
mini_portile (0.5.1)
|
|
60
|
+
minitest (4.7.5)
|
|
61
|
+
multi_json (1.8.0)
|
|
62
|
+
nokogiri (1.6.0)
|
|
63
|
+
mini_portile (~> 0.5.0)
|
|
64
|
+
poltergeist (1.4.1)
|
|
65
|
+
capybara (~> 2.1.0)
|
|
66
|
+
cliver (~> 0.2.1)
|
|
67
|
+
multi_json (~> 1.0)
|
|
68
|
+
websocket-driver (>= 0.2.0)
|
|
54
69
|
polyglot (0.3.3)
|
|
55
|
-
rack (1.
|
|
56
|
-
rack-cache (1.2)
|
|
57
|
-
rack (>= 0.4)
|
|
58
|
-
rack-ssl (1.3.3)
|
|
59
|
-
rack
|
|
70
|
+
rack (1.5.2)
|
|
60
71
|
rack-test (0.6.2)
|
|
61
72
|
rack (>= 1.0)
|
|
62
|
-
rails (
|
|
63
|
-
actionmailer (=
|
|
64
|
-
actionpack (=
|
|
65
|
-
activerecord (=
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
railties (
|
|
71
|
-
actionpack (=
|
|
72
|
-
activesupport (=
|
|
73
|
-
rack-ssl (~> 1.3.2)
|
|
73
|
+
rails (4.0.0)
|
|
74
|
+
actionmailer (= 4.0.0)
|
|
75
|
+
actionpack (= 4.0.0)
|
|
76
|
+
activerecord (= 4.0.0)
|
|
77
|
+
activesupport (= 4.0.0)
|
|
78
|
+
bundler (>= 1.3.0, < 2.0)
|
|
79
|
+
railties (= 4.0.0)
|
|
80
|
+
sprockets-rails (~> 2.0.0)
|
|
81
|
+
railties (4.0.0)
|
|
82
|
+
actionpack (= 4.0.0)
|
|
83
|
+
activesupport (= 4.0.0)
|
|
74
84
|
rake (>= 0.8.7)
|
|
75
|
-
|
|
76
|
-
thor (>= 0.14.6, < 2.0)
|
|
85
|
+
thor (>= 0.18.1, < 2.0)
|
|
77
86
|
rake (10.1.0)
|
|
78
|
-
rdoc (
|
|
87
|
+
rdoc (4.0.1)
|
|
79
88
|
json (~> 1.4)
|
|
80
|
-
rspec-core (2.14.
|
|
81
|
-
rspec-expectations (2.14.
|
|
89
|
+
rspec-core (2.14.5)
|
|
90
|
+
rspec-expectations (2.14.3)
|
|
82
91
|
diff-lcs (>= 1.1.3, < 2.0)
|
|
83
|
-
rspec-mocks (2.14.
|
|
92
|
+
rspec-mocks (2.14.3)
|
|
84
93
|
rspec-rails (2.14.0)
|
|
85
94
|
actionpack (>= 3.0)
|
|
86
95
|
activesupport (>= 3.0)
|
|
@@ -88,32 +97,44 @@ GEM
|
|
|
88
97
|
rspec-core (~> 2.14.0)
|
|
89
98
|
rspec-expectations (~> 2.14.0)
|
|
90
99
|
rspec-mocks (~> 2.14.0)
|
|
91
|
-
shoulda-matchers (2.
|
|
100
|
+
shoulda-matchers (2.4.0)
|
|
92
101
|
activesupport (>= 3.0.0)
|
|
93
|
-
sprockets (2.
|
|
102
|
+
sprockets (2.10.0)
|
|
94
103
|
hike (~> 1.2)
|
|
95
104
|
multi_json (~> 1.0)
|
|
96
105
|
rack (~> 1.0)
|
|
97
106
|
tilt (~> 1.1, != 1.3.0)
|
|
98
|
-
|
|
107
|
+
sprockets-rails (2.0.0)
|
|
108
|
+
actionpack (>= 3.0)
|
|
109
|
+
activesupport (>= 3.0)
|
|
110
|
+
sprockets (~> 2.8)
|
|
111
|
+
sqlite3 (1.3.8)
|
|
99
112
|
thor (0.18.1)
|
|
113
|
+
thread_safe (0.1.3)
|
|
114
|
+
atomic
|
|
100
115
|
tilt (1.4.1)
|
|
101
|
-
treetop (1.4.
|
|
116
|
+
treetop (1.4.15)
|
|
102
117
|
polyglot
|
|
103
118
|
polyglot (>= 0.3.1)
|
|
104
119
|
tzinfo (0.3.37)
|
|
120
|
+
websocket-driver (0.3.0)
|
|
105
121
|
xml-simple (1.1.2)
|
|
122
|
+
xpath (2.0.0)
|
|
123
|
+
nokogiri (~> 1.3)
|
|
106
124
|
|
|
107
125
|
PLATFORMS
|
|
108
126
|
ruby
|
|
109
127
|
|
|
110
128
|
DEPENDENCIES
|
|
111
129
|
aws-s3
|
|
130
|
+
capybara
|
|
112
131
|
ffaker
|
|
113
132
|
gem-release (~> 0.6)
|
|
114
133
|
generator_spec
|
|
115
|
-
rails
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
134
|
+
jquery-rails
|
|
135
|
+
poltergeist
|
|
136
|
+
rails (~> 4.0)
|
|
137
|
+
rdoc (~> 4.0)
|
|
138
|
+
rspec-rails (~> 2.14)
|
|
139
|
+
shoulda-matchers (~> 2.4)
|
|
119
140
|
sqlite3
|
data/README.md
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
# S3CorsFileupload
|
|
1
|
+
# S3CorsFileupload [](http://badge.fury.io/rb/s3_cors_fileupload) [](https://travis-ci.org/fullbridge-batkins/s3_cors_fileupload)
|
|
2
2
|
|
|
3
3
|
A gem to allow for uploading of files to directly AWS-S3 via [CORS](http://www.w3.org/TR/cors/) using the
|
|
4
4
|
[jQuery-File-Upload javascript](http://blueimp.github.com/jQuery-File-Upload/) for Rails 3.1 and greater.
|
|
5
5
|
|
|
6
|
+
*Note: your application must include [jQuery](http://jquery.com/) for the plugin to work properly,
|
|
7
|
+
either through the [`jquery-rails` gem](https://github.com/rails/jquery-rails), or some other means.*
|
|
8
|
+
|
|
6
9
|
### Included JavaScript plugin versions
|
|
7
10
|
|
|
8
|
-
* jQuery File Upload User Interface Plugin 8.5
|
|
9
|
-
* jQuery File Upload Plugin 5.32.
|
|
11
|
+
* jQuery File Upload User Interface Plugin 8.8.5
|
|
12
|
+
* jQuery File Upload Plugin 5.32.6
|
|
10
13
|
* jQuery UI Widget 1.10.3+amd
|
|
11
14
|
|
|
12
15
|
### Upgrade notes for `0.2` (and higher) releases
|
|
13
16
|
|
|
14
17
|
If you are upgrading from an older version, please re-run the install generator with the `--skip-migration` option.
|
|
15
18
|
The view templates (`_template_download`, `_template_upload`, `_template_uploaded`) often change to stay compatible with
|
|
16
|
-
the new version(s) of the jQuery-File-Upload UI JavaScript.
|
|
19
|
+
the new version(s) of the jQuery-File-Upload UI JavaScript. You will also need to re-compile your asset pipeline assets to
|
|
20
|
+
get the latest versions of the javascript plugins if you precompile your assets.
|
|
17
21
|
|
|
18
22
|
## Installation
|
|
19
23
|
Add this line to your application's Gemfile:
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
require 'rails/generators'
|
|
2
2
|
require 'rails/generators/migration'
|
|
3
|
-
require 'rails/generators/active_record
|
|
3
|
+
require 'rails/generators/active_record'
|
|
4
4
|
|
|
5
5
|
module S3CorsFileupload
|
|
6
6
|
module Generators
|
|
7
7
|
class InstallGenerator < ::Rails::Generators::Base
|
|
8
8
|
include ::Rails::Generators::Migration
|
|
9
|
-
extend ActiveRecord::Generators::Migration
|
|
10
9
|
|
|
11
10
|
VALID_TEMPLATE_LANGS = [:erb, :haml]
|
|
12
11
|
|
|
@@ -50,6 +49,10 @@ module S3CorsFileupload
|
|
|
50
49
|
)
|
|
51
50
|
end
|
|
52
51
|
|
|
52
|
+
def self.next_migration_number(dirname)
|
|
53
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
|
54
|
+
end
|
|
55
|
+
|
|
53
56
|
end
|
|
54
57
|
end
|
|
55
58
|
end
|
|
@@ -13,7 +13,9 @@ class S3UploadsController < ApplicationController
|
|
|
13
13
|
# POST /source_files
|
|
14
14
|
# POST /source_files.json
|
|
15
15
|
def create
|
|
16
|
-
|
|
16
|
+
# this line allows for compatibility with `ProtectedAttributes` or `StrongParameters`
|
|
17
|
+
parameters = S3CorsFileupload.active_record_protected_attributes? ? params[:source_file] : params.require(:source_file).permit(:url, :bucket, :key)
|
|
18
|
+
@source_file = SourceFile.new(parameters)
|
|
17
19
|
respond_to do |format|
|
|
18
20
|
if @source_file.save
|
|
19
21
|
format.html {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
require 'aws/s3'
|
|
2
2
|
|
|
3
3
|
class SourceFile < ActiveRecord::Base
|
|
4
|
-
|
|
4
|
+
# This line can be removed for Rails 4 apps that are using Strong Parameters
|
|
5
|
+
attr_accessible :url, :bucket, :key if S3CorsFileupload.active_record_protected_attributes?
|
|
5
6
|
|
|
6
7
|
validates_presence_of :file_name, :file_content_type, :file_size, :key, :bucket
|
|
7
8
|
|
|
@@ -9,8 +10,8 @@ class SourceFile < ActiveRecord::Base
|
|
|
9
10
|
self.file_name = key.split('/').last if key
|
|
10
11
|
# for some reason, the response from AWS seems to escape the slashes in the keys, this line will unescape the slash
|
|
11
12
|
self.url = url.gsub(/%2F/, '/') if url
|
|
12
|
-
self.file_size ||= s3_object.
|
|
13
|
-
self.file_content_type ||= s3_object.
|
|
13
|
+
self.file_size ||= s3_object.size rescue nil
|
|
14
|
+
self.file_content_type ||= s3_object.content_type rescue nil
|
|
14
15
|
end
|
|
15
16
|
# make all attributes readonly after creating the record (not sure we need this?)
|
|
16
17
|
after_create { readonly! }
|
data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_download.html.erb
CHANGED
|
@@ -11,21 +11,32 @@
|
|
|
11
11
|
</td>
|
|
12
12
|
<td>
|
|
13
13
|
<p class="name">
|
|
14
|
-
|
|
14
|
+
{% if (file.url) { %}
|
|
15
|
+
<a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl ? 'data-gallery' : ''%}>{%=file.name%}</a>
|
|
16
|
+
{% } else { %}
|
|
17
|
+
<span>{%=file.name%}</span>
|
|
18
|
+
{% } %}
|
|
15
19
|
</p>
|
|
16
20
|
{% if (file.error) { %}
|
|
17
|
-
<div><span class="label label-
|
|
21
|
+
<div><span class="label label-danger">Error</span> {%=file.error%}</div>
|
|
18
22
|
{% } %}
|
|
19
23
|
</td>
|
|
20
24
|
<td>
|
|
21
25
|
<span class="size">{%=o.formatFileSize(file.size)%}</span>
|
|
22
26
|
</td>
|
|
23
27
|
<td>
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
{% if (file.deleteUrl) { %}
|
|
29
|
+
<button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}" data-confirmation="Are you sure?" {% if (file.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
|
|
30
|
+
<i class="glyphicon glyphicon-trash"></i>
|
|
31
|
+
<span>Delete</span>
|
|
32
|
+
</button>
|
|
33
|
+
<input type="checkbox" name="delete" value="1" class="toggle">
|
|
34
|
+
{% } else { %}
|
|
35
|
+
<button class="btn btn-warning cancel">
|
|
36
|
+
<i class="glyphicon glyphicon-ban-circle"></i>
|
|
37
|
+
<span>Cancel</span>
|
|
38
|
+
</button>
|
|
39
|
+
{% } %}
|
|
29
40
|
</td>
|
|
30
41
|
</tr>
|
|
31
42
|
{% } %}
|
data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_upload.html.erb
CHANGED
|
@@ -8,25 +8,25 @@
|
|
|
8
8
|
<td>
|
|
9
9
|
<p class="name">{%=file.name%}</p>
|
|
10
10
|
{% if (file.error) { %}
|
|
11
|
-
<div><span class="label label-
|
|
11
|
+
<div><span class="label label-danger">Error</span> {%=file.error%}</div>
|
|
12
12
|
{% } %}
|
|
13
13
|
</td>
|
|
14
14
|
<td>
|
|
15
15
|
<p class="size">{%=o.formatFileSize(file.size)%}</p>
|
|
16
16
|
{% if (!o.files.error) { %}
|
|
17
|
-
<div class="progress progress-
|
|
17
|
+
<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-success" style="width:0%;"></div></div>
|
|
18
18
|
{% } %}
|
|
19
19
|
</td>
|
|
20
20
|
<td>
|
|
21
21
|
{% if (!o.files.error && !i && !o.options.autoUpload) { %}
|
|
22
22
|
<button class="btn btn-primary start">
|
|
23
|
-
<i class="
|
|
23
|
+
<i class="glyphicon glyphicon-upload"></i>
|
|
24
24
|
<span>Start</span>
|
|
25
25
|
</button>
|
|
26
26
|
{% } %}
|
|
27
27
|
{% if (!i) { %}
|
|
28
28
|
<button class="btn btn-warning cancel">
|
|
29
|
-
<i class="
|
|
29
|
+
<i class="glyphicon glyphicon-ban-circle"></i>
|
|
30
30
|
<span>Cancel</span>
|
|
31
31
|
</button>
|
|
32
32
|
{% } %}
|
data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_uploaded.html.erb
CHANGED
|
@@ -13,18 +13,29 @@
|
|
|
13
13
|
</td>
|
|
14
14
|
<td>
|
|
15
15
|
<p class="name">
|
|
16
|
-
|
|
16
|
+
{% if (o.url) { %}
|
|
17
|
+
<a href="{%=o.url%}" title="{%=o.name%}" download="{%=o.name%}" {%=o.image ? 'data-gallery' : ''%}>{%=o.name%}</a>
|
|
18
|
+
{% } else { %}
|
|
19
|
+
<span>{%=o.name%}</span>
|
|
20
|
+
{% } %}
|
|
17
21
|
</p>
|
|
18
22
|
</td>
|
|
19
23
|
<td>
|
|
20
24
|
<span class="size">{%=formatFileSize(o.size)%}</span>
|
|
21
25
|
</td>
|
|
22
26
|
<td>
|
|
23
|
-
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
{% if (o.delete_url) { %}
|
|
28
|
+
<button class="btn btn-danger delete" data-type="DELETE" data-url="{%=o.delete_url%}" data-object_id="{%=o.id%}" data-confirmation="Are you sure?" {% if (o.delete_with_credentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
|
|
29
|
+
<i class="glyphicon glyphicon-trash"></i>
|
|
30
|
+
<span>Delete</span>
|
|
31
|
+
</button>
|
|
32
|
+
<input type="checkbox" name="delete" value="1" class="toggle">
|
|
33
|
+
{% } else { %}
|
|
34
|
+
<button class="btn btn-warning cancel">
|
|
35
|
+
<i class="glyphicon glyphicon-ban-circle"></i>
|
|
36
|
+
<span>Cancel</span>
|
|
37
|
+
</button>
|
|
38
|
+
{% } %}
|
|
28
39
|
</td>
|
|
29
40
|
</tr>
|
|
30
41
|
</script>
|