1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #33795 from marceloperini/marceloperini/33450-active-storage

Fix zero-byte files upload in #33630
This commit is contained in:
Rafael França 2018-09-11 17:56:29 -04:00 committed by GitHub
commit e9ae7a1514
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -15,6 +15,10 @@ module ActiveStorage::Blob::Identifiable
end end
def download_identifiable_chunk def download_identifiable_chunk
service.download_chunk key, 0...4.kilobytes if byte_size.positive?
service.download_chunk key, 0...4.kilobytes
else
""
end
end end
end end

View file

View file

@ -31,6 +31,13 @@ if SERVICE_CONFIGURATIONS[:s3]
end end
end end
test "upload a zero byte file" do
blob = directly_upload_file_blob filename: "empty_file.txt", content_type: nil
user = User.create! name: "DHH", avatar: blob
assert_equal user.avatar.blob, blob
end
test "signed URL generation" do test "signed URL generation" do
url = @service.url(@key, expires_in: 5.minutes, url = @service.url(@key, expires_in: 5.minutes,
disposition: :inline, filename: ActiveStorage::Filename.new("avatar.png"), content_type: "image/png") disposition: :inline, filename: ActiveStorage::Filename.new("avatar.png"), content_type: "image/png")