module Scrivito # @api public # The FutureBinary class represents the data to be stored in a binary field. # See {Scrivito::Binary.upload} and {Scrivito::Binary#copy} for details. class FutureBinary attr_reader :filename, :content_type, :id_to_be_copied, :file_to_be_uploaded def initialize(filename:, content_type:, id_to_be_copied: nil, file_to_be_uploaded: nil) @filename = filename @content_type = content_type || content_type_of_filename(filename) @id_to_be_copied = id_to_be_copied @file_to_be_uploaded = file_to_be_uploaded end private def content_type_of_filename(filename) MIME::Types.type_for(filename).first.try(:content_type) end end end