From 0ed18d9671ea7189e737be3d9f7b9f915c31c390 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 6 Jul 2017 15:35:48 +0200 Subject: [PATCH] This is even more explaining and upload/download don't have some inherent need to synchronize chunk sizes anyway --- lib/active_storage/service/disk_service.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/active_storage/service/disk_service.rb b/lib/active_storage/service/disk_service.rb index dc7491310b..7981226a1e 100644 --- a/lib/active_storage/service/disk_service.rb +++ b/lib/active_storage/service/disk_service.rb @@ -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