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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e37b68386a3a7becb2363f72f3ce38e8b9049a9a
4
- data.tar.gz: 5391ed9991a220136287ad472d243c0ee5164492
2
+ SHA256:
3
+ metadata.gz: 80780b748c8964a6099525d3c094c95b0c39902a76a7be6c4a1f091fca8675bc
4
+ data.tar.gz: 13a35e088f2b6c4ca84c1b58848b0127ddf3bd39c96c7838eda68f98acc4ec48
5
5
  SHA512:
6
- metadata.gz: 2cfc444237e06625db981b6a502847d9a64bd52dc7a7fd4a5189ffc878914fdf7f252d504b54b49d13cb63b2c7d90afdbabaee3b6fb482a3c8bcec49546a51da
7
- data.tar.gz: 637ee1e7a31c735ff3b9fd7035e7cc897e8acfc610eadeb8c96de778c9b8c64d4a9bcb2e80fe1ed63454e35a029a8ea8224eb3022a748f8a8caa134b9f2048c3
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
- rake db:migrate
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
- rake db:migrate
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
- rake db:migrate
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}"
@@ -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}"
@@ -341,11 +341,7 @@ module CarrierWave
341
341
  end
342
342
 
343
343
  def mini_magick_image
344
- if url
345
- ::MiniMagick::Image.open(url)
346
- else
347
- ::MiniMagick::Image.open(current_path)
348
- end
344
+ ::MiniMagick::Image.read(read)
349
345
  end
350
346
 
351
347
  end # MiniMagick
@@ -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
- local_file.url(expire_at, options)
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 @uploader.fog_credentials[:provider].to_s
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 @uploader.fog_directory.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\d{1,3}){3}$))(?:[a-z0-9\.]|(?![\-])|\-(?![\.])){1,61}[a-z0-9]$/
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
- {'x-amz-acl' => @uploader.fog_public ? 'public-read' : 'private'}
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
 
@@ -1,3 +1,3 @@
1
1
  module CarrierWave
2
- VERSION = "1.2.3"
2
+ VERSION = "1.3.0"
3
3
  end
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.2.3
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-06-30 00:00:00.000000000 Z
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: 0.1.0
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: 0.1.0
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.5.2
323
+ rubygems_version: 2.7.6
324
324
  signing_key:
325
325
  specification_version: 4
326
326
  summary: Ruby file upload library