instance method
compute_checksum
Ruby on Rails edge
Since edgeSignature
compute_checksum(io, **options)
No documentation comment.
Parameters
-
ioreq -
optionskeyrest
Source
# File activestorage/lib/active_storage/service.rb, line 156
def compute_checksum(io, **options)
raise ArgumentError, "io must be rewindable" unless io.respond_to?(:rewind)
# Defer to Digest class's file implementation if File or base64digest if no chunk_size
return checksum_implementation(**options).file(io).base64digest if io.is_a?(File)
return checksum_implementation(**options).base64digest(io.read) if default_chunk_size.to_i == 0
checksum_implementation(**options).new.tap do |checksum|
read_buffer = "".b
while io.read(default_chunk_size, read_buffer)
checksum << read_buffer
end
io.rewind
end.base64digest
end
Defined in activestorage/lib/active_storage/service.rb line 156
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveStorage::Service