From 771ca41240036f2e5da0b90fa5f3ef14b2c13ae8 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Fri, 21 Aug 2020 19:11:21 +0200 Subject: [PATCH] Added helper methods for screenshots --- app/models/screenshot.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/models/screenshot.rb b/app/models/screenshot.rb index 9e9cb75..7816186 100644 --- a/app/models/screenshot.rb +++ b/app/models/screenshot.rb @@ -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