Class: Shrine::Plugins::KitheChecksumSignatures
- Inherits:
-
Object
- Object
- Shrine::Plugins::KitheChecksumSignatures
- Defined in:
- lib/shrine/plugins/kithe_checksum_signatures.rb
Overview
Using the shrine signature and add_metadata plugins, ensure that the shrine standard digest/checksum signatures are recorded in metadata.
This plugin is NOT included in Kithe::AssetUploader by default, include it in your local uploader if desired.
We want to store md5 and sha1 checksums (legacy compat), as well as sha512 (more recent digital preservation recommendation: ocfl.io/draft/spec/#digests)
We only calculate them only on promotion action (not cache action), to avoid needlessly expensive double-computation, and because for direct uploads/backgrounding, we haven’t actually gotten the file in our hands to compute checksums until then anyway.
the add_metadata plugin’s ‘metadata_method` is used to make md5, sha1, and sha512 methods available on the Attacher. (They also end up delegated from the Asset model)
Class Method Summary collapse
Class Method Details
.configure(uploader, opts = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/shrine/plugins/kithe_checksum_signatures.rb', line 24 def self.configure(uploader, opts = {}) uploader.class_eval do do |io, derivative:nil, **context| if context[:action] != :cache && derivative.nil? { md5: calculate_signature(io, :md5), sha1: calculate_signature(io, :sha1), sha512: calculate_signature(io, :sha512) } end end :md5, :sha1, :sha512 end end |
.load_dependencies(uploader) ⇒ Object
19 20 21 22 |
# File 'lib/shrine/plugins/kithe_checksum_signatures.rb', line 19 def self.load_dependencies(uploader, *) uploader.plugin :add_metadata uploader.plugin :signature end |