lib/lockbox/carrier_wave_extensions.rb in lockbox-0.3.5 vs lib/lockbox/carrier_wave_extensions.rb in lockbox-0.3.6

- old
+ new

@@ -6,16 +6,22 @@ def encrypt(file) @file = CarrierWave::SanitizedFile.new(lockbox.encrypt_io(file)) end + # TODO safe to memoize? def read r = super lockbox.decrypt(r) if r end def size read.bytesize + end + + # based on CarrierWave::SanitizedFile#mime_magic_content_type + def content_type + MimeMagic.by_magic(read).try(:type) || "invalid/invalid" end def rotate_encryption! io = Lockbox::IO.new(read) io.original_filename = file.filename