carrierwave 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of carrierwave might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/README.md +4 -4
- data/lib/carrierwave.rb +20 -0
- data/lib/carrierwave/locale/en.yml +1 -1
- data/lib/carrierwave/processing/mini_magick.rb +1 -5
- data/lib/carrierwave/storage/file.rb +1 -1
- data/lib/carrierwave/storage/fog.rb +28 -5
- data/lib/carrierwave/uploader/content_type_whitelist.rb +1 -1
- data/lib/carrierwave/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 80780b748c8964a6099525d3c094c95b0c39902a76a7be6c4a1f091fca8675bc
|
4
|
+
data.tar.gz: 13a35e088f2b6c4ca84c1b58848b0127ddf3bd39c96c7838eda68f98acc4ec48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd8c38e8b598c781b532cefeaf4ca21dcc0309a0ce7dc89817ccc9464777dae7e3a9afda1b308c9013b6d145df1b250d231401d291d1efde4e150dcc53c76dac
|
7
|
+
data.tar.gz: d578c1b64632ae62ccae75f2c1f0f4f0941104a88ce0745c2de0de016105f05436f33111fe8a9b79eadcb68b0bc3890c9b735da5db6bdd24b5662ad24e3dcdfb
|
data/README.md
CHANGED
@@ -89,7 +89,7 @@ a migration:
|
|
89
89
|
|
90
90
|
|
91
91
|
rails g migration add_avatar_to_users avatar:string
|
92
|
-
|
92
|
+
rails db:migrate
|
93
93
|
|
94
94
|
Open your model file and mount the uploader:
|
95
95
|
|
@@ -144,12 +144,12 @@ example, create a migration like this:
|
|
144
144
|
#### For databases with ActiveRecord json data type support (e.g. PostgreSQL, MySQL)
|
145
145
|
|
146
146
|
rails g migration add_avatars_to_users avatars:json
|
147
|
-
|
147
|
+
rails db:migrate
|
148
148
|
|
149
149
|
#### For database without ActiveRecord json data type support (e.g. SQLite)
|
150
150
|
|
151
151
|
rails g migration add_avatars_to_users avatars:string
|
152
|
-
|
152
|
+
rails db:migrate
|
153
153
|
|
154
154
|
__Note__: JSON datatype doesn't exists in SQLite adapter, that's why you can use a string datatype which will be serialized in model.
|
155
155
|
|
@@ -923,7 +923,7 @@ errors:
|
|
923
923
|
carrierwave_download_error: could not be downloaded
|
924
924
|
extension_whitelist_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}"
|
925
925
|
extension_blacklist_error: "You are not allowed to upload %{extension} files, prohibited types: %{prohibited_types}"
|
926
|
-
content_type_whitelist_error: "You are not allowed to upload %{content_type} files"
|
926
|
+
content_type_whitelist_error: "You are not allowed to upload %{content_type} files, allowed types: %{allowed_types}"
|
927
927
|
content_type_blacklist_error: "You are not allowed to upload %{content_type} files"
|
928
928
|
rmagick_processing_error: "Failed to manipulate with rmagick, maybe it is not an image?"
|
929
929
|
mini_magick_processing_error: "Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: %{e}"
|
data/lib/carrierwave.rb
CHANGED
@@ -34,6 +34,26 @@ if defined?(Merb)
|
|
34
34
|
Dir.glob(File.join(Merb.load_paths[:uploaders])).each {|f| require f }
|
35
35
|
end
|
36
36
|
|
37
|
+
elsif defined?(Jets)
|
38
|
+
|
39
|
+
module CarrierWave
|
40
|
+
class Turbine < Jets::Turbine
|
41
|
+
initializer "carrierwave.setup_paths" do |app|
|
42
|
+
CarrierWave.root = Jets.root.to_s
|
43
|
+
CarrierWave.tmp_path = "/tmp/carrierwave"
|
44
|
+
CarrierWave.configure do |config|
|
45
|
+
config.cache_dir = "/tmp/carrierwave/uploads/tmp"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
initializer "carrierwave.active_record" do
|
50
|
+
ActiveSupport.on_load :active_record do
|
51
|
+
require 'carrierwave/orm/activerecord'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
37
57
|
elsif defined?(Rails)
|
38
58
|
|
39
59
|
module CarrierWave
|
@@ -6,7 +6,7 @@ en:
|
|
6
6
|
carrierwave_download_error: could not be downloaded
|
7
7
|
extension_whitelist_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}"
|
8
8
|
extension_blacklist_error: "You are not allowed to upload %{extension} files, prohibited types: %{prohibited_types}"
|
9
|
-
content_type_whitelist_error: "You are not allowed to upload %{content_type} files"
|
9
|
+
content_type_whitelist_error: "You are not allowed to upload %{content_type} files, allowed types: %{allowed_types}"
|
10
10
|
content_type_blacklist_error: "You are not allowed to upload %{content_type} files"
|
11
11
|
rmagick_processing_error: "Failed to manipulate with rmagick, maybe it is not an image?"
|
12
12
|
mini_magick_processing_error: "Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: %{e}"
|
@@ -66,7 +66,7 @@ module CarrierWave
|
|
66
66
|
#
|
67
67
|
def cache!(new_file)
|
68
68
|
new_file.move_to(::File.expand_path(uploader.cache_path, uploader.root), uploader.permissions, uploader.directory_permissions, true)
|
69
|
-
rescue Errno::EMLINK => e
|
69
|
+
rescue Errno::EMLINK, Errno::ENOSPC => e
|
70
70
|
raise(e) if @cache_called
|
71
71
|
@cache_called = true
|
72
72
|
|
@@ -192,8 +192,14 @@ module CarrierWave
|
|
192
192
|
local_file = local_directory.files.new(:key => path)
|
193
193
|
expire_at = ::Fog::Time.now + @uploader.fog_authenticated_url_expiration
|
194
194
|
case @uploader.fog_credentials[:provider]
|
195
|
-
when 'AWS'
|
196
|
-
|
195
|
+
when 'AWS', 'Google'
|
196
|
+
# Older versions of fog-google do not support options as a parameter
|
197
|
+
if url_options_supported?(local_file)
|
198
|
+
local_file.url(expire_at, options)
|
199
|
+
else
|
200
|
+
warn "Options hash not supported in #{local_file.class}. You may need to upgrade your Fog provider."
|
201
|
+
local_file.url(expire_at)
|
202
|
+
end
|
197
203
|
when 'Rackspace'
|
198
204
|
connection.get_object_https_url(@uploader.fog_directory, path, expire_at, options)
|
199
205
|
when 'OpenStack'
|
@@ -352,15 +358,19 @@ module CarrierWave
|
|
352
358
|
end
|
353
359
|
else
|
354
360
|
# AWS/Google optimized for speed over correctness
|
355
|
-
case
|
361
|
+
case fog_provider
|
356
362
|
when 'AWS'
|
357
363
|
# check if some endpoint is set in fog_credentials
|
358
364
|
if @uploader.fog_credentials.has_key?(:endpoint)
|
359
365
|
"#{@uploader.fog_credentials[:endpoint]}/#{@uploader.fog_directory}/#{encoded_path}"
|
360
366
|
else
|
361
367
|
protocol = @uploader.fog_use_ssl_for_aws ? "https" : "http"
|
368
|
+
|
369
|
+
subdomain_regex = /^(?:[a-z]|\d(?!\d{0,2}(?:\d{1,3}){3}$))(?:[a-z0-9\.]|(?![\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
370
|
+
valid_subdomain = @uploader.fog_directory.to_s =~ subdomain_regex && !(protocol == 'https' && @uploader.fog_directory =~ /\./)
|
371
|
+
|
362
372
|
# if directory is a valid subdomain, use that style for access
|
363
|
-
if
|
373
|
+
if valid_subdomain
|
364
374
|
s3_subdomain = @uploader.fog_aws_accelerate ? "s3-accelerate" : "s3"
|
365
375
|
"#{protocol}://#{@uploader.fog_directory}.#{s3_subdomain}.amazonaws.com/#{encoded_path}"
|
366
376
|
else
|
@@ -466,7 +476,15 @@ module CarrierWave
|
|
466
476
|
end
|
467
477
|
|
468
478
|
def acl_header
|
469
|
-
|
479
|
+
if fog_provider == 'AWS'
|
480
|
+
{ 'x-amz-acl' => @uploader.fog_public ? 'public-read' : 'private' }
|
481
|
+
else
|
482
|
+
{}
|
483
|
+
end
|
484
|
+
end
|
485
|
+
|
486
|
+
def fog_provider
|
487
|
+
@uploader.fog_credentials[:provider].to_s
|
470
488
|
end
|
471
489
|
|
472
490
|
def read_source_file(file_body)
|
@@ -479,6 +497,11 @@ module CarrierWave
|
|
479
497
|
file_body.close
|
480
498
|
end
|
481
499
|
end
|
500
|
+
|
501
|
+
def url_options_supported?(local_file)
|
502
|
+
parameters = file.method(:url).parameters
|
503
|
+
parameters.count == 2 && parameters[1].include?(:options)
|
504
|
+
end
|
482
505
|
end
|
483
506
|
|
484
507
|
end # Fog
|
@@ -35,7 +35,7 @@ module CarrierWave
|
|
35
35
|
def check_content_type_whitelist!(new_file)
|
36
36
|
content_type = new_file.content_type
|
37
37
|
if content_type_whitelist && !whitelisted_content_type?(content_type)
|
38
|
-
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.content_type_whitelist_error", content_type: content_type)
|
38
|
+
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.content_type_whitelist_error", content_type: content_type, allowed_types: Array(content_type_whitelist).join(", "))
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
data/lib/carrierwave/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -140,16 +140,16 @@ dependencies:
|
|
140
140
|
name: fog-google
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 1.7.1
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 1.7.1
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: fog-local
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -320,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
320
320
|
version: '0'
|
321
321
|
requirements: []
|
322
322
|
rubyforge_project:
|
323
|
-
rubygems_version: 2.
|
323
|
+
rubygems_version: 2.7.6
|
324
324
|
signing_key:
|
325
325
|
specification_version: 4
|
326
326
|
summary: Ruby file upload library
|