activestorage 6.0.4 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +141 -187
- data/MIT-LICENSE +1 -1
- data/README.md +36 -4
- data/app/controllers/active_storage/base_controller.rb +11 -0
- data/app/controllers/active_storage/blobs/proxy_controller.rb +14 -0
- data/app/controllers/active_storage/{blobs_controller.rb → blobs/redirect_controller.rb} +2 -2
- data/app/controllers/active_storage/disk_controller.rb +8 -20
- data/app/controllers/active_storage/representations/proxy_controller.rb +19 -0
- data/app/controllers/active_storage/{representations_controller.rb → representations/redirect_controller.rb} +2 -2
- data/app/controllers/concerns/active_storage/file_server.rb +18 -0
- data/app/controllers/concerns/active_storage/set_blob.rb +1 -1
- data/app/controllers/concerns/active_storage/set_current.rb +2 -2
- data/app/controllers/concerns/active_storage/set_headers.rb +12 -0
- data/app/jobs/active_storage/mirror_job.rb +15 -0
- data/app/models/active_storage/attachment.rb +18 -10
- data/app/models/active_storage/blob.rb +114 -57
- data/app/models/active_storage/blob/analyzable.rb +6 -2
- data/app/models/active_storage/blob/identifiable.rb +7 -6
- data/app/models/active_storage/blob/representable.rb +34 -4
- data/app/models/active_storage/preview.rb +31 -10
- data/app/models/active_storage/record.rb +7 -0
- data/app/models/active_storage/variant.rb +28 -41
- data/app/models/active_storage/variant_record.rb +8 -0
- data/app/models/active_storage/variant_with_record.rb +54 -0
- data/app/models/active_storage/variation.rb +25 -20
- data/config/routes.rb +58 -8
- data/db/migrate/20170806125915_create_active_storage_tables.rb +14 -5
- data/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb +17 -0
- data/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +11 -0
- data/lib/active_storage.rb +5 -2
- data/lib/active_storage/analyzer.rb +6 -0
- data/lib/active_storage/analyzer/image_analyzer.rb +3 -0
- data/lib/active_storage/analyzer/null_analyzer.rb +4 -0
- data/lib/active_storage/analyzer/video_analyzer.rb +14 -3
- data/lib/active_storage/attached/changes/create_many.rb +1 -0
- data/lib/active_storage/attached/changes/create_one.rb +17 -4
- data/lib/active_storage/attached/many.rb +4 -3
- data/lib/active_storage/attached/model.rb +49 -10
- data/lib/active_storage/attached/one.rb +4 -3
- data/lib/active_storage/engine.rb +25 -27
- data/lib/active_storage/gem_version.rb +3 -3
- data/lib/active_storage/log_subscriber.rb +6 -0
- data/lib/active_storage/previewer.rb +3 -2
- data/lib/active_storage/previewer/mupdf_previewer.rb +3 -3
- data/lib/active_storage/previewer/poppler_pdf_previewer.rb +2 -2
- data/lib/active_storage/previewer/video_previewer.rb +2 -2
- data/lib/active_storage/service.rb +35 -7
- data/lib/active_storage/service/azure_storage_service.rb +40 -35
- data/lib/active_storage/service/configurator.rb +3 -1
- data/lib/active_storage/service/disk_service.rb +36 -31
- data/lib/active_storage/service/gcs_service.rb +18 -16
- data/lib/active_storage/service/mirror_service.rb +31 -7
- data/lib/active_storage/service/registry.rb +32 -0
- data/lib/active_storage/service/s3_service.rb +51 -23
- data/lib/active_storage/transformers/image_processing_transformer.rb +13 -7
- data/lib/active_storage/transformers/transformer.rb +0 -3
- metadata +57 -21
- data/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb +0 -9
- data/lib/active_storage/downloading.rb +0 -47
- data/lib/active_storage/transformers/mini_magick_transformer.rb +0 -38
@@ -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
|