Class: Valkyrie::Shrine::Checksum::S3
- Defined in:
- lib/valkyrie/shrine/checksum/s3.rb
Instance Attribute Summary collapse
-
#part_size ⇒ Object
readonly
Returns the value of attribute part_size.
-
#threshold ⇒ Object
readonly
Returns the value of attribute threshold.
Class Method Summary collapse
Instance Method Summary collapse
- #calculate_checksum(result) ⇒ Object
- #checksum_for(io) ⇒ Object
-
#initialize(threshold: 15 * 1024 * 1024, part_size: 5 * 1024 * 1024) ⇒ S3
constructor
A new instance of S3.
Methods inherited from Base
#digest_class, #simple_digest, #verify_checksum
Constructor Details
#initialize(threshold: 15 * 1024 * 1024, part_size: 5 * 1024 * 1024) ⇒ S3
Returns a new instance of S3.
13 14 15 16 |
# File 'lib/valkyrie/shrine/checksum/s3.rb', line 13 def initialize(threshold: 15 * 1024 * 1024, part_size: 5 * 1024 * 1024) @threshold = threshold @part_size = part_size end |
Instance Attribute Details
#part_size ⇒ Object (readonly)
Returns the value of attribute part_size.
7 8 9 |
# File 'lib/valkyrie/shrine/checksum/s3.rb', line 7 def part_size @part_size end |
#threshold ⇒ Object (readonly)
Returns the value of attribute threshold.
7 8 9 |
# File 'lib/valkyrie/shrine/checksum/s3.rb', line 7 def threshold @threshold end |
Class Method Details
.digest_class ⇒ Object
9 10 11 |
# File 'lib/valkyrie/shrine/checksum/s3.rb', line 9 def self.digest_class Digest::MD5 end |
Instance Method Details
#calculate_checksum(result) ⇒ Object
18 19 20 |
# File 'lib/valkyrie/shrine/checksum/s3.rb', line 18 def calculate_checksum(result) result.io.data[:object].data.etag.delete('"') end |
#checksum_for(io) ⇒ Object
22 23 24 25 |
# File 'lib/valkyrie/shrine/checksum/s3.rb', line 22 def checksum_for(io) io.rewind io.size < threshold ? simple_digest(io) : multipart_checksum(io) end |