class Ollama::Commands::PushBlob
command = Ollama::Commands::PushBlob.new(body: File.open(‘model.gguf’, ‘rb’))
@example Preparing a push blob command with a file
required SHA256 digest to target the correct API endpoint.
It accepts the content to be uploaded and automatically calculates the
This class is used to upload raw binary files (blobs) to the Ollama server.
A command class that represents the push blob API endpoint for Ollama.
def initialize(body:, digest: nil)
-
digest(String, nil) -- optional precomputed SHA256 digest. If provided, -
body(IO, String) -- the binary content or file handle to upload
def initialize(body:, digest: nil) @body = body.respond_to?(:read) ? body : StringIO.new(body.to_str) digest = prefix_sha256(digest) @digest = digest || compute_digest(@body) @stream = false end
def path
-
(String)- the API endpoint path '/api/blobs/'
def path "/api/blobs/#{digest}" end
def perform(handler)
-
(self)- returns the current instance after initiating the request
Parameters:
-
handler(Ollama::Handler) -- the handler object responsible for processing API responses
def perform(handler) @client.blob_exists?(digest) or @client.upload_file(path:, body:, handler:) handler.result = digest self end