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

Fix zero-byte files upload

This commit is contained in:
Marcelo Perini Veloso 2018-09-05 00:21:44 -03:00
parent 5bd4a4c78b
commit 0d4ba40688
3 changed files with 12 additions and 1 deletions

View file

@ -15,6 +15,10 @@ module ActiveStorage::Blob::Identifiable
end
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

View file

View file

@ -31,6 +31,13 @@ if SERVICE_CONFIGURATIONS[:s3]
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
url = @service.url(@key, expires_in: 5.minutes,
disposition: :inline, filename: ActiveStorage::Filename.new("avatar.png"), content_type: "image/png")