Added helper methods for screenshots

This commit is contained in:
Christoph Haas 2020-08-21 19:11:21 +02:00
parent cfe6790179
commit 771ca41240

View file

@ -148,4 +148,19 @@ class Screenshot < ApplicationRecord
self.version.split(/[\-\+]/).first
end
# Returns the path to this screenshot's image on disk
def disk_path
ActiveStorage::Blob.service.send(:path_for, self.image.key)
end
def checksum
# local files stored on disk:
# url = "#{Rails.root}/public/#{attachment.path}"
Digest::MD5.hexdigest(disk_path)
# remote files stored on another person's computer:
#url = attachment.url
#Digest::MD5.base64digest(Net::HTTP.get(URI(url)))
end
end