From 74ddc80590053b04b90c35ae3e1f46bfbd9d0d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mica=C3=ABl=20Bergeron?= Date: Mon, 29 Jan 2018 16:06:17 -0500 Subject: add the uploader context to the upload model --- app/models/upload.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'app/models/upload.rb') diff --git a/app/models/upload.rb b/app/models/upload.rb index fb55fd8007b..28baee95091 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -30,7 +30,8 @@ class Upload < ActiveRecord::Base end def build_uploader - uploader_class.new(model).tap do |uploader| + uploader_class.new(model, mount_point, **uploader_context) + .tap do |uploader| uploader.upload = self uploader.retrieve_from_store!(identifier) end @@ -40,6 +41,13 @@ class Upload < ActiveRecord::Base File.exist?(absolute_path) end + def uploader_context + { + identifier: identifier, + secret: secret + }.compact + end + private def checksummable? @@ -62,11 +70,15 @@ class Upload < ActiveRecord::Base !path.start_with?('/') end + def uploader_class + Object.const_get(uploader) + end + def identifier File.basename(path) end - def uploader_class - Object.const_get(uploader) + def mount_point + super&.to_sym end end -- cgit v1.2.1