module NATS::Objects

Overview

The NATS object store is S3-style object storage backed by NATS JetStream.

You can access the object store API with NATS::Client#objects.

Create a bucket with Objects::Client#create_bucket:

bucket = nats.objects.create_bucket("my-bucket")

Add an object from a file on disk (for example, from a tempfile created from an HTTP file upload) with Objects::Bucket#put:

File.open filename do |file|
  bucket.put "my-key", file
end

Get the metadata from an object in the store with Objects::Bucket#get_info:

bucket.get_info("my-key")

Get the contents of an object in the store with Objects::Bucket#get, which returns an IO instance that you can read from gradually to avoid having to load the entire object into memory. For example, for storing large images or videos.

if io = bucket.get("my-key")
  io.gets_to_end
end

EXPERIMENTAL NATS object store is experimental and the API could change

Defined in:

objects.cr

Constant Summary

DEFAULT_CHUNK_SIZE = 128 * 1024