activestorage 6.0.4.6 → 6.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activestorage might be problematic. Click here for more details.

Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +137 -213
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +36 -4
  5. data/app/controllers/active_storage/base_controller.rb +11 -0
  6. data/app/controllers/active_storage/blobs/proxy_controller.rb +14 -0
  7. data/app/controllers/active_storage/{blobs_controller.rb → blobs/redirect_controller.rb} +2 -2
  8. data/app/controllers/active_storage/disk_controller.rb +8 -20
  9. data/app/controllers/active_storage/representations/proxy_controller.rb +19 -0
  10. data/app/controllers/active_storage/{representations_controller.rb → representations/redirect_controller.rb} +2 -2
  11. data/app/controllers/concerns/active_storage/file_server.rb +18 -0
  12. data/app/controllers/concerns/active_storage/set_blob.rb +1 -1
  13. data/app/controllers/concerns/active_storage/set_current.rb +2 -2
  14. data/app/controllers/concerns/active_storage/set_headers.rb +12 -0
  15. data/app/jobs/active_storage/mirror_job.rb +15 -0
  16. data/app/models/active_storage/attachment.rb +18 -10
  17. data/app/models/active_storage/blob/analyzable.rb +6 -2
  18. data/app/models/active_storage/blob/identifiable.rb +7 -6
  19. data/app/models/active_storage/blob/representable.rb +34 -4
  20. data/app/models/active_storage/blob.rb +114 -57
  21. data/app/models/active_storage/preview.rb +31 -10
  22. data/app/models/active_storage/record.rb +7 -0
  23. data/app/models/active_storage/variant.rb +28 -41
  24. data/app/models/active_storage/variant_record.rb +8 -0
  25. data/app/models/active_storage/variant_with_record.rb +54 -0
  26. data/app/models/active_storage/variation.rb +25 -20
  27. data/config/routes.rb +58 -8
  28. data/db/migrate/20170806125915_create_active_storage_tables.rb +14 -5
  29. data/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb +17 -0
  30. data/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +11 -0
  31. data/lib/active_storage/analyzer/image_analyzer.rb +3 -0
  32. data/lib/active_storage/analyzer/null_analyzer.rb +4 -0
  33. data/lib/active_storage/analyzer/video_analyzer.rb +14 -3
  34. data/lib/active_storage/analyzer.rb +6 -0
  35. data/lib/active_storage/attached/changes/create_many.rb +1 -0
  36. data/lib/active_storage/attached/changes/create_one.rb +17 -4
  37. data/lib/active_storage/attached/many.rb +4 -3
  38. data/lib/active_storage/attached/model.rb +49 -10
  39. data/lib/active_storage/attached/one.rb +4 -3
  40. data/lib/active_storage/engine.rb +25 -27
  41. data/lib/active_storage/gem_version.rb +3 -3
  42. data/lib/active_storage/log_subscriber.rb +6 -0
  43. data/lib/active_storage/previewer/mupdf_previewer.rb +3 -3
  44. data/lib/active_storage/previewer/poppler_pdf_previewer.rb +2 -2
  45. data/lib/active_storage/previewer/video_previewer.rb +2 -2
  46. data/lib/active_storage/previewer.rb +3 -2
  47. data/lib/active_storage/service/azure_storage_service.rb +40 -35
  48. data/lib/active_storage/service/configurator.rb +3 -1
  49. data/lib/active_storage/service/disk_service.rb +36 -31
  50. data/lib/active_storage/service/gcs_service.rb +18 -16
  51. data/lib/active_storage/service/mirror_service.rb +31 -7
  52. data/lib/active_storage/service/registry.rb +32 -0
  53. data/lib/active_storage/service/s3_service.rb +51 -23
  54. data/lib/active_storage/service.rb +35 -7
  55. data/lib/active_storage/transformers/image_processing_transformer.rb +13 -7
  56. data/lib/active_storage/transformers/transformer.rb +0 -3
  57. data/lib/active_storage.rb +5 -2
  58. metadata +60 -24
  59. data/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb +0 -9
  60. data/lib/active_storage/downloading.rb +0 -47
  61. data/lib/active_storage/transformers/mini_magick_transformer.rb +0 -38
@@ -9,20 +9,29 @@ module ActiveStorage
9
9
  # Wraps the Amazon Simple Storage Service (S3) as an Active Storage service.
10
10
  # See ActiveStorage::Service for the generic API documentation that applies to all services.
11
11
  class Service::S3Service < Service
12
- attr_reader :client, :bucket, :upload_options
12
+ attr_reader :client, :bucket
13
+ attr_reader :multipart_upload_threshold, :upload_options
13
14
 
14
- def initialize(bucket:, upload: {}, **options)
15
+ def initialize(bucket:, upload: {}, public: false, **options)
15
16
  @client = Aws::S3::Resource.new(**options)
16
17
  @bucket = @client.bucket(bucket)
17
18
 
19
+ @multipart_upload_threshold = upload.fetch(:multipart_threshold, 100.megabytes)
20
+ @public = public
21
+
18
22
  @upload_options = upload
23
+ @upload_options[:acl] = "public-read" if public?
19
24
  end
20
25
 
21
- def upload(key, io, checksum: nil, content_type: nil, **)
26
+ def upload(key, io, checksum: nil, filename: nil, content_type: nil, disposition: nil, **)
22
27
  instrument :upload, key: key, checksum: checksum do
23
- object_for(key).put(upload_options.merge(body: io, content_md5: checksum, content_type: content_type))
24
- rescue Aws::S3::Errors::BadDigest
25
- raise ActiveStorage::IntegrityError
28
+ content_disposition = content_disposition_with(filename: filename, type: disposition) if disposition && filename
29
+
30
+ if io.size < multipart_upload_threshold
31
+ upload_with_single_part key, io, checksum: checksum, content_type: content_type, content_disposition: content_disposition
32
+ else
33
+ upload_with_multipart key, io, content_type: content_type, content_disposition: content_disposition
34
+ end
26
35
  end
27
36
  end
28
37
 
@@ -42,7 +51,7 @@ module ActiveStorage
42
51
 
43
52
  def download_chunk(key, range)
44
53
  instrument :download_chunk, key: key, range: range do
45
- object_for(key).get(range: "bytes=#{range.begin}-#{range.exclude_end? ? range.end - 1 : range.end}").body.read.force_encoding(Encoding::BINARY)
54
+ object_for(key).get(range: "bytes=#{range.begin}-#{range.exclude_end? ? range.end - 1 : range.end}").body.string.force_encoding(Encoding::BINARY)
46
55
  rescue Aws::S3::Errors::NoSuchKey
47
56
  raise ActiveStorage::FileNotFoundError
48
57
  end
@@ -68,23 +77,11 @@ module ActiveStorage
68
77
  end
69
78
  end
70
79
 
71
- def url(key, expires_in:, filename:, disposition:, content_type:)
72
- instrument :url, key: key do |payload|
73
- generated_url = object_for(key).presigned_url :get, expires_in: expires_in.to_i,
74
- response_content_disposition: content_disposition_with(type: disposition, filename: filename),
75
- response_content_type: content_type
76
-
77
- payload[:url] = generated_url
78
-
79
- generated_url
80
- end
81
- end
82
-
83
80
  def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:)
84
81
  instrument :url, key: key do |payload|
85
82
  generated_url = object_for(key).presigned_url :put, expires_in: expires_in.to_i,
86
83
  content_type: content_type, content_length: content_length, content_md5: checksum,
87
- whitelist_headers: ['content-length']
84
+ whitelist_headers: ["content-length"], **upload_options
88
85
 
89
86
  payload[:url] = generated_url
90
87
 
@@ -92,11 +89,42 @@ module ActiveStorage
92
89
  end
93
90
  end
94
91
 
95
- def headers_for_direct_upload(key, content_type:, checksum:, **)
96
- { "Content-Type" => content_type, "Content-MD5" => checksum }
92
+ def headers_for_direct_upload(key, content_type:, checksum:, filename: nil, disposition: nil, **)
93
+ content_disposition = content_disposition_with(type: disposition, filename: filename) if filename
94
+
95
+ { "Content-Type" => content_type, "Content-MD5" => checksum, "Content-Disposition" => content_disposition }
97
96
  end
98
97
 
99
98
  private
99
+ def private_url(key, expires_in:, filename:, disposition:, content_type:, **)
100
+ object_for(key).presigned_url :get, expires_in: expires_in.to_i,
101
+ response_content_disposition: content_disposition_with(type: disposition, filename: filename),
102
+ response_content_type: content_type
103
+ end
104
+
105
+ def public_url(key, **)
106
+ object_for(key).public_url
107
+ end
108
+
109
+
110
+ MAXIMUM_UPLOAD_PARTS_COUNT = 10000
111
+ MINIMUM_UPLOAD_PART_SIZE = 5.megabytes
112
+
113
+ def upload_with_single_part(key, io, checksum: nil, content_type: nil, content_disposition: nil)
114
+ object_for(key).put(body: io, content_md5: checksum, content_type: content_type, content_disposition: content_disposition, **upload_options)
115
+ rescue Aws::S3::Errors::BadDigest
116
+ raise ActiveStorage::IntegrityError
117
+ end
118
+
119
+ def upload_with_multipart(key, io, content_type: nil, content_disposition: nil)
120
+ part_size = [ io.size.fdiv(MAXIMUM_UPLOAD_PARTS_COUNT).ceil, MINIMUM_UPLOAD_PART_SIZE ].max
121
+
122
+ object_for(key).upload_stream(content_type: content_type, content_disposition: content_disposition, part_size: part_size, **upload_options) do |out|
123
+ IO.copy_stream(io, out)
124
+ end
125
+ end
126
+
127
+
100
128
  def object_for(key)
101
129
  bucket.object(key)
102
130
  end
@@ -111,7 +139,7 @@ module ActiveStorage
111
139
  raise ActiveStorage::FileNotFoundError unless object.exists?
112
140
 
113
141
  while offset < object.content_length
114
- yield object.get(range: "bytes=#{offset}-#{offset + chunk_size - 1}").body.read.force_encoding(Encoding::BINARY)
142
+ yield object.get(range: "bytes=#{offset}-#{offset + chunk_size - 1}").body.string.force_encoding(Encoding::BINARY)
115
143
  offset += chunk_size
116
144
  end
117
145
  end
@@ -41,6 +41,7 @@ module ActiveStorage
41
41
  class Service
42
42
  extend ActiveSupport::Autoload
43
43
  autoload :Configurator
44
+ attr_accessor :name
44
45
 
45
46
  class << self
46
47
  # Configure an Active Storage service by name from a set of configurations,
@@ -56,8 +57,10 @@ module ActiveStorage
56
57
  # Passes the configurator and all of the service's config as keyword args.
57
58
  #
58
59
  # See MirrorService for an example.
59
- def build(configurator:, service: nil, **service_config) #:nodoc:
60
- new(**service_config)
60
+ def build(configurator:, name:, service: nil, **service_config) #:nodoc:
61
+ new(**service_config).tap do |service_instance|
62
+ service_instance.name = name
63
+ end
61
64
  end
62
65
  end
63
66
 
@@ -102,11 +105,23 @@ module ActiveStorage
102
105
  raise NotImplementedError
103
106
  end
104
107
 
105
- # Returns a signed, temporary URL for the file at the +key+. The URL will be valid for the amount
106
- # of seconds specified in +expires_in+. You must also provide the +disposition+ (+:inline+ or +:attachment+),
107
- # +filename+, and +content_type+ that you wish the file to be served with on request.
108
- def url(key, expires_in:, disposition:, filename:, content_type:)
109
- raise NotImplementedError
108
+ # Returns the URL for the file at the +key+. This returns a permanent URL for public files, and returns a
109
+ # short-lived URL for private files. For private files you can provide the +disposition+ (+:inline+ or +:attachment+),
110
+ # +filename+, and +content_type+ that you wish the file to be served with on request. Additionally, you can also provide
111
+ # the amount of seconds the URL will be valid for, specified in +expires_in+.
112
+ def url(key, **options)
113
+ instrument :url, key: key do |payload|
114
+ generated_url =
115
+ if public?
116
+ public_url(key, **options)
117
+ else
118
+ private_url(key, **options)
119
+ end
120
+
121
+ payload[:url] = generated_url
122
+
123
+ generated_url
124
+ end
110
125
  end
111
126
 
112
127
  # Returns a signed, temporary URL that a direct upload file can be PUT to on the +key+.
@@ -122,7 +137,20 @@ module ActiveStorage
122
137
  {}
123
138
  end
124
139
 
140
+ def public?
141
+ @public
142
+ end
143
+
125
144
  private
145
+ def private_url(key, expires_in:, filename:, disposition:, content_type:, **)
146
+ raise NotImplementedError
147
+ end
148
+
149
+ def public_url(key, **)
150
+ raise NotImplementedError
151
+ end
152
+
153
+
126
154
  def instrument(operation, payload = {}, &block)
127
155
  ActiveSupport::Notifications.instrument(
128
156
  "service_#{operation}.active_storage",
@@ -1,6 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "image_processing"
3
+ begin
4
+ require "image_processing"
5
+ rescue LoadError
6
+ raise LoadError, <<~ERROR.squish
7
+ Generating image variants require the image_processing gem.
8
+ Please add `gem 'image_processing', '~> 1.2'` to your Gemfile.
9
+ ERROR
10
+ end
4
11
 
5
12
  module ActiveStorage
6
13
  module Transformers
@@ -22,14 +29,13 @@ module ActiveStorage
22
29
  def operations
23
30
  transformations.each_with_object([]) do |(name, argument), list|
24
31
  if name.to_s == "combine_options"
25
- ActiveSupport::Deprecation.warn <<~WARNING.squish
32
+ raise ArgumentError, <<~ERROR.squish
26
33
  Active Storage's ImageProcessing transformer doesn't support :combine_options,
27
- as it always generates a single ImageMagick command. Passing :combine_options will
28
- not be supported in Rails 6.1.
29
- WARNING
34
+ as it always generates a single ImageMagick command.
35
+ ERROR
36
+ end
30
37
 
31
- list.concat argument.keep_if { |key, value| value.present? }.to_a
32
- elsif argument.present?
38
+ if argument.present?
33
39
  list << [ name, argument ]
34
40
  end
35
41
  end
@@ -8,9 +8,6 @@ module ActiveStorage
8
8
  #
9
9
  # * ActiveStorage::Transformers::ImageProcessingTransformer:
10
10
  # backed by ImageProcessing, a common interface for MiniMagick and ruby-vips
11
- #
12
- # * ActiveStorage::Transformers::MiniMagickTransformer:
13
- # backed by MiniMagick, a wrapper around the ImageMagick CLI
14
11
  class Transformer
15
12
  attr_reader :transformations
16
13
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2017-2019 David Heinemeier Hansson, Basecamp
4
+ # Copyright (c) 2017-2020 David Heinemeier Hansson, Basecamp
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
@@ -53,6 +53,7 @@ module ActiveStorage
53
53
  mattr_accessor :paths, default: {}
54
54
 
55
55
  mattr_accessor :variable_content_types, default: []
56
+ mattr_accessor :web_image_content_types, default: []
56
57
  mattr_accessor :binary_content_type, default: "application/octet-stream"
57
58
  mattr_accessor :content_types_to_serve_as_binary, default: []
58
59
  mattr_accessor :content_types_allowed_inline, default: []
@@ -60,14 +61,16 @@ module ActiveStorage
60
61
  mattr_accessor :service_urls_expire_in, default: 5.minutes
61
62
 
62
63
  mattr_accessor :routes_prefix, default: "/rails/active_storage"
64
+ mattr_accessor :draw_routes, default: true
65
+ mattr_accessor :resolve_model_to_route, default: :rails_storage_redirect
63
66
 
64
67
  mattr_accessor :replace_on_assign_to_many, default: false
68
+ mattr_accessor :track_variants, default: false
65
69
 
66
70
  module Transformers
67
71
  extend ActiveSupport::Autoload
68
72
 
69
73
  autoload :Transformer
70
74
  autoload :ImageProcessingTransformer
71
- autoload :MiniMagickTransformer
72
75
  end
73
76
  end
metadata CHANGED
@@ -1,71 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.4.6
4
+ version: 6.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-11 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.0.rc1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 6.1.0.rc1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: actionpack
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - '='
18
32
  - !ruby/object:Gem::Version
19
- version: 6.0.4.6
33
+ version: 6.1.0.rc1
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - '='
25
39
  - !ruby/object:Gem::Version
26
- version: 6.0.4.6
40
+ version: 6.1.0.rc1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: activejob
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - '='
32
46
  - !ruby/object:Gem::Version
33
- version: 6.0.4.6
47
+ version: 6.1.0.rc1
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - '='
39
53
  - !ruby/object:Gem::Version
40
- version: 6.0.4.6
54
+ version: 6.1.0.rc1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: activerecord
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - '='
46
60
  - !ruby/object:Gem::Version
47
- version: 6.0.4.6
61
+ version: 6.1.0.rc1
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - '='
53
67
  - !ruby/object:Gem::Version
54
- version: 6.0.4.6
68
+ version: 6.1.0.rc1
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: marcel
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: 1.0.0
75
+ version: 0.3.1
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 1.0.0
82
+ version: 0.3.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: mimemagic
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.3.2
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.3.2
69
97
  description: Attach cloud and local files in Rails applications.
70
98
  email: david@loudthinking.com
71
99
  executables: []
@@ -77,12 +105,16 @@ files:
77
105
  - README.md
78
106
  - app/assets/javascripts/activestorage.js
79
107
  - app/controllers/active_storage/base_controller.rb
80
- - app/controllers/active_storage/blobs_controller.rb
108
+ - app/controllers/active_storage/blobs/proxy_controller.rb
109
+ - app/controllers/active_storage/blobs/redirect_controller.rb
81
110
  - app/controllers/active_storage/direct_uploads_controller.rb
82
111
  - app/controllers/active_storage/disk_controller.rb
83
- - app/controllers/active_storage/representations_controller.rb
112
+ - app/controllers/active_storage/representations/proxy_controller.rb
113
+ - app/controllers/active_storage/representations/redirect_controller.rb
114
+ - app/controllers/concerns/active_storage/file_server.rb
84
115
  - app/controllers/concerns/active_storage/set_blob.rb
85
116
  - app/controllers/concerns/active_storage/set_current.rb
117
+ - app/controllers/concerns/active_storage/set_headers.rb
86
118
  - app/javascript/activestorage/blob_record.js
87
119
  - app/javascript/activestorage/blob_upload.js
88
120
  - app/javascript/activestorage/direct_upload.js
@@ -94,6 +126,7 @@ files:
94
126
  - app/javascript/activestorage/ujs.js
95
127
  - app/jobs/active_storage/analyze_job.rb
96
128
  - app/jobs/active_storage/base_job.rb
129
+ - app/jobs/active_storage/mirror_job.rb
97
130
  - app/jobs/active_storage/purge_job.rb
98
131
  - app/models/active_storage/attachment.rb
99
132
  - app/models/active_storage/blob.rb
@@ -103,11 +136,15 @@ files:
103
136
  - app/models/active_storage/current.rb
104
137
  - app/models/active_storage/filename.rb
105
138
  - app/models/active_storage/preview.rb
139
+ - app/models/active_storage/record.rb
106
140
  - app/models/active_storage/variant.rb
141
+ - app/models/active_storage/variant_record.rb
142
+ - app/models/active_storage/variant_with_record.rb
107
143
  - app/models/active_storage/variation.rb
108
144
  - config/routes.rb
109
145
  - db/migrate/20170806125915_create_active_storage_tables.rb
110
- - db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb
146
+ - db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb
147
+ - db/update_migrate/20191206030411_create_active_storage_variant_records.rb
111
148
  - lib/active_storage.rb
112
149
  - lib/active_storage/analyzer.rb
113
150
  - lib/active_storage/analyzer/image_analyzer.rb
@@ -124,7 +161,6 @@ files:
124
161
  - lib/active_storage/attached/model.rb
125
162
  - lib/active_storage/attached/one.rb
126
163
  - lib/active_storage/downloader.rb
127
- - lib/active_storage/downloading.rb
128
164
  - lib/active_storage/engine.rb
129
165
  - lib/active_storage/errors.rb
130
166
  - lib/active_storage/gem_version.rb
@@ -140,9 +176,9 @@ files:
140
176
  - lib/active_storage/service/disk_service.rb
141
177
  - lib/active_storage/service/gcs_service.rb
142
178
  - lib/active_storage/service/mirror_service.rb
179
+ - lib/active_storage/service/registry.rb
143
180
  - lib/active_storage/service/s3_service.rb
144
181
  - lib/active_storage/transformers/image_processing_transformer.rb
145
- - lib/active_storage/transformers/mini_magick_transformer.rb
146
182
  - lib/active_storage/transformers/transformer.rb
147
183
  - lib/active_storage/version.rb
148
184
  - lib/tasks/activestorage.rake
@@ -151,11 +187,11 @@ licenses:
151
187
  - MIT
152
188
  metadata:
153
189
  bug_tracker_uri: https://github.com/rails/rails/issues
154
- changelog_uri: https://github.com/rails/rails/blob/v6.0.4.6/activestorage/CHANGELOG.md
155
- documentation_uri: https://api.rubyonrails.org/v6.0.4.6/
190
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.0.rc1/activestorage/CHANGELOG.md
191
+ documentation_uri: https://api.rubyonrails.org/v6.1.0.rc1/
156
192
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
157
- source_code_uri: https://github.com/rails/rails/tree/v6.0.4.6/activestorage
158
- post_install_message:
193
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.0.rc1/activestorage
194
+ post_install_message:
159
195
  rdoc_options: []
160
196
  require_paths:
161
197
  - lib
@@ -166,12 +202,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
202
  version: 2.5.0
167
203
  required_rubygems_version: !ruby/object:Gem::Requirement
168
204
  requirements:
169
- - - ">="
205
+ - - ">"
170
206
  - !ruby/object:Gem::Version
171
- version: '0'
207
+ version: 1.3.1
172
208
  requirements: []
173
- rubygems_version: 3.2.22
174
- signing_key:
209
+ rubygems_version: 3.1.4
210
+ signing_key:
175
211
  specification_version: 4
176
212
  summary: Local and cloud file storage framework.
177
213
  test_files: []
@@ -1,9 +0,0 @@
1
- class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
2
- def up
3
- return if foreign_key_exists?(:active_storage_attachments, column: :blob_id)
4
-
5
- if table_exists?(:active_storage_blobs)
6
- add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id
7
- end
8
- end
9
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "tmpdir"
4
- require "active_support/core_ext/string/filters"
5
-
6
- module ActiveStorage
7
- module Downloading
8
- def self.included(klass)
9
- ActiveSupport::Deprecation.warn <<~MESSAGE.squish, caller_locations(2)
10
- ActiveStorage::Downloading is deprecated and will be removed in Active Storage 6.1.
11
- Use ActiveStorage::Blob#open instead.
12
- MESSAGE
13
- end
14
-
15
- private
16
- # Opens a new tempfile in #tempdir and copies blob data into it. Yields the tempfile.
17
- def download_blob_to_tempfile #:doc:
18
- open_tempfile_for_blob do |file|
19
- download_blob_to file
20
- yield file
21
- end
22
- end
23
-
24
- def open_tempfile_for_blob
25
- tempfile = Tempfile.open([ "ActiveStorage", blob.filename.extension_with_delimiter ], tempdir)
26
-
27
- begin
28
- yield tempfile
29
- ensure
30
- tempfile.close!
31
- end
32
- end
33
-
34
- # Efficiently downloads blob data into the given file.
35
- def download_blob_to(file) #:doc:
36
- file.binmode
37
- blob.download { |chunk| file.write(chunk) }
38
- file.flush
39
- file.rewind
40
- end
41
-
42
- # Returns the directory in which tempfiles should be opened. Defaults to +Dir.tmpdir+.
43
- def tempdir #:doc:
44
- Dir.tmpdir
45
- end
46
- end
47
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "mini_magick"
4
-
5
- module ActiveStorage
6
- module Transformers
7
- class MiniMagickTransformer < Transformer
8
- private
9
- def process(file, format:)
10
- image = MiniMagick::Image.new(file.path, file)
11
-
12
- transformations.each do |name, argument_or_subtransformations|
13
- image.mogrify do |command|
14
- if name.to_s == "combine_options"
15
- argument_or_subtransformations.each do |subtransformation_name, subtransformation_argument|
16
- pass_transform_argument(command, subtransformation_name, subtransformation_argument)
17
- end
18
- else
19
- pass_transform_argument(command, name, argument_or_subtransformations)
20
- end
21
- end
22
- end
23
-
24
- image.format(format) if format
25
-
26
- image.tempfile.tap(&:open)
27
- end
28
-
29
- def pass_transform_argument(command, method, argument)
30
- if argument == true
31
- command.public_send(method)
32
- elsif argument.present?
33
- command.public_send(method, argument)
34
- end
35
- end
36
- end
37
- end
38
- end