require 'scrivito/cms_rest_api.rb' module Scrivito class CmsRestApi # Stub upload_future_binary since the uploads are handled directly in ruby. def self.upload_future_binary(future_binary, obj_id) file = future_binary.file_to_upload # TODO: code deduplication with obj builder parent = Fiona7::WriteObj.find(obj_id.to_i) ext = ::File.extname(file.path).to_s[1..-1] name = ::File.basename(file.path, '.' + ext.to_s) obj_class = if ['jpg', 'jpeg', 'gif', 'png', 'tif', 'tiff'].include?(ext) 'X_Image' else 'X_Generic' end raise Scrivito::ScrivitoError.new("File extension of uploaded file cannot be identified", 422) if ext.nil? upload = Fiona7::WriteObj.upload(file, ext, {name: name, parent: parent, obj_class: obj_class}).tap(&:release!) encoded_id = '%032d' % upload.id {'id' => encoded_id} end def self.activate_upload(*args) raise "This method is not implemented" end end end