mirror of https://github.com/rails/rails
Set Content-Type on variant uploads
This commit is contained in:
parent
60d3c14a73
commit
698e9ce0ff
|
@ -1,3 +1,7 @@
|
|||
* The `Content-Type` header is set on image variants when they're uploaded to third-party storage services.
|
||||
|
||||
*Kyle Ribordy*
|
||||
|
||||
* Allow storage services to be configured per attachment
|
||||
|
||||
```ruby
|
||||
|
|
|
@ -98,7 +98,7 @@ class ActiveStorage::Variant
|
|||
def process
|
||||
blob.open do |input|
|
||||
variation.transform(input, format: format) do |output|
|
||||
service.upload(key, output)
|
||||
service.upload(key, output, content_type: content_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -196,4 +196,16 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
|
|||
ensure
|
||||
ActiveStorage.variant_processor = :mini_magick
|
||||
end
|
||||
|
||||
test "passes content_type on upload" do
|
||||
blob = create_file_blob(filename: "racecar.jpg", content_type: "image/jpeg")
|
||||
|
||||
mock_upload = lambda do |_, _, options = {}|
|
||||
assert_equal options[:content_type], "image/jpeg"
|
||||
end
|
||||
|
||||
blob.service.stub(:upload, mock_upload) do
|
||||
blob.variant(resize: "100x100").processed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue