Module: Paperdragon::File::Rename

Included in:
Paperdragon::File
Defined in:
lib/paperdragon/file/operations.rb

Instance Method Summary collapse

Instance Method Details

#rename!(fingerprint, metadata = {}) {|old_uid, uid| ... } ⇒ Object

fixme: we are currently ignoring the custom metadata.

Yields:

  • (old_uid, uid)


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/paperdragon/file/operations.rb', line 56

def rename!(fingerprint, ={}) # fixme: we are currently ignoring the custom metadata.
  old_uid = uid
  uid!(fingerprint)

  puts "........................MV:
    #{old_uid}
    #{uid}"
  # dragonfly_s3 = Dragonfly.app.datastore
  # Dragonfly.app.datastore.storage.copy_object(dragonfly_s3.bucket_name, old_uid, dragonfly_s3.bucket_name, uid, {'x-amz-acl' => 'public-read', "Content-Type" => "image/jpeg"})
  yield old_uid, uid

  puts "........................DELETE: #{old_uid}"
  Dragonfly.app.destroy(old_uid)


  self..merge(:uid => uid) # usually, metadata is already set to the old metadata when File was created via Attachment.
end