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

This is even more explaining and upload/download don't have some inherent need to synchronize chunk sizes anyway

This commit is contained in:
David Heinemeier Hansson 2017-07-06 15:35:48 +02:00
parent 89e8b86546
commit 0ed18d9671

View file

@ -2,8 +2,6 @@ require "fileutils"
require "pathname"
class ActiveStorage::Service::DiskService < ActiveStorage::Service
CHUNK_SIZE = 65536
attr_reader :root
def initialize(root:)
@ -12,7 +10,7 @@ class ActiveStorage::Service::DiskService < ActiveStorage::Service
def upload(key, io)
File.open(make_path_for(key), "wb") do |file|
while chunk = io.read(CHUNK_SIZE)
while chunk = io.read(64.kilobytes)
file.write(chunk)
end
end
@ -21,7 +19,7 @@ class ActiveStorage::Service::DiskService < ActiveStorage::Service
def download(key)
if block_given?
File.open(path_for(key)) do |file|
while data = file.read(CHUNK_SIZE)
while data = file.read(64.kilobytes)
yield data
end
end