提交 1986048d 编写于 作者: G Graham Conzett

Fix issue ActiveStorage direct upload disk

Fix an issue in ActiveStorage where a direct upload to disk storage
would fail due to a content type mismatch if the file was uploaded using
a mime-type synonym.
上级 44295409
......@@ -61,6 +61,7 @@ def decode_verified_token
end
def acceptable_content?(token)
token[:content_type] == request.content_type && token[:content_length] == request.content_length
Mime::Type.lookup(request.content_type) == token[:content_type] &&
token[:content_length] == request.content_length
end
end
......@@ -67,6 +67,16 @@ class ActiveStorage::DiskControllerTest < ActionDispatch::IntegrationTest
assert_not blob.service.exist?(blob.key)
end
test "directly uploading blob with different but equivalent content type" do
data = "Something else entirely!"
blob = create_blob_before_direct_upload(
byte_size: data.size, checksum: Digest::MD5.base64digest(data), content_type: "application/x-gzip")
put blob.service_url_for_direct_upload, params: data, headers: { "Content-Type" => "application/x-gzip" }
assert_response :no_content
assert_equal data, blob.download
end
test "directly uploading blob with mismatched content length" do
data = "Something else entirely!"
blob = create_blob_before_direct_upload byte_size: data.size - 1, checksum: Digest::MD5.base64digest(data)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册