mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Halve memory allocation in S3Service#download
Aws::S3::Object#get returns a response with object content wrapped in an in-memory StringIO object. StringIO#read will return a copy of the content, which is not necessary because we can return the content directly using StringIO#string. This halves memory allocation of S3Service#download, because we remove unnecessary content duplication.
This commit is contained in:
parent
80cbf19453
commit
19770d6ca3
1 changed files with 1 additions and 1 deletions
|
@ -33,7 +33,7 @@ module ActiveStorage
|
|||
end
|
||||
else
|
||||
instrument :download, key: key do
|
||||
object_for(key).get.body.read.force_encoding(Encoding::BINARY)
|
||||
object_for(key).get.body.string.force_encoding(Encoding::BINARY)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue