mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Stream blobs from disk in 5 MB chunks
Match other services, which all use a 5 MB chunk size.
This commit is contained in:
parent
8781b03b7e
commit
5f2ee4c0bb
2 changed files with 4 additions and 4 deletions
|
@ -26,7 +26,7 @@ module ActiveStorage
|
|||
if block_given?
|
||||
instrument :streaming_download, key: key do
|
||||
File.open(path_for(key), "rb") do |file|
|
||||
while data = file.read(64.kilobytes)
|
||||
while data = file.read(5.megabytes)
|
||||
yield data
|
||||
end
|
||||
end
|
||||
|
|
|
@ -62,7 +62,7 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test "download yields chunks" do
|
||||
blob = create_blob data: "a" * 75.kilobytes
|
||||
blob = create_blob data: "a" * 5.0625.megabytes
|
||||
chunks = []
|
||||
|
||||
blob.download do |chunk|
|
||||
|
@ -70,8 +70,8 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
assert_equal 2, chunks.size
|
||||
assert_equal "a" * 64.kilobytes, chunks.first
|
||||
assert_equal "a" * 11.kilobytes, chunks.second
|
||||
assert_equal "a" * 5.megabytes, chunks.first
|
||||
assert_equal "a" * 64.kilobytes, chunks.second
|
||||
end
|
||||
|
||||
test "urls expiring in 5 minutes" do
|
||||
|
|
Loading…
Reference in a new issue