require 'scrivito/binary' module Scrivito # This class had been reworked to support uploads directly # into CMS and not into S3 class Binary # new implementation def content_type if shadow_obj shadow_obj.mime_type end end def content_length if shadow_obj shadow_obj.body_length else 0 end end def filename if shadow_obj shadow_obj.name + '.' + shadow_obj.file_extension end end # New API call. Allows to read the extension of the stored file. def file_extension if shadow_obj shadow_obj.file_extension end end # New API call. Allows to access the contents of the blob. def content if shadow_obj shadow_obj.body end end def url ActiveSupport::Deprecation.warn("This method should never be called. Use scrivito_path or scrvito_url whenever possible") if shadow_obj Rails.application.routes.url_helpers.fiona7_blob_path(id: @id, name: self.filename) end end private def shadow_obj @shadow_obj ||= Fiona7::InternalReleasedObj.find(@id.to_i) if @id.to_i != 0 end end end