require 'fiona7/builder/indirect_blob_builder' require 'fiona7/upload_path_selector' require 'fiona7/blob_id_generator' module Fiona7 # This class uploads a file into a temporary location to be reused later. # It returns the blob id of the uploaded file. class TemporaryUploader def initialize(file, filename, obj_id=nil) @file = file @filename = filename @obj_id = obj_id end def call obj = Builder::IndirectBlobBuilder.new(upload_path, @filename, @file).call BlobIdGenerator.new(obj.obj_id, obj.last_changed).call end private def upload_path if Fiona7.mode == :standalone dest_obj = Fiona7::WriteObj.find(@obj_id) rescue nil if dest_obj return UploadPathSelector.new(dest_obj).call end end # TODO: legacy '/_uploads/temp' end end end