Object Store Walkthrough
If you are running a local nats-server stop it and restart it with JetStream enabled using nats-server -js (if that's not already done)
You can then check that JetStream is enabled by using
nats account infoWhich should output something like:
Connection Information:
Client ID: 6
Client IP: 127.0.0.1
RTT: 64.996µs
Headers Supported: true
Maximum Payload: 1.0 MiB
Connected URL: nats://127.0.0.1:4222
Connected Address: 127.0.0.1:4222
Connected Server ID: ND2XVDA4Q363JOIFKJTPZW3ZKZCANH7NJI4EJMFSSPTRXDBFG4M4C34K
JetStream Account Information:
Memory: 0 B of Unlimited
Storage: 0 B of Unlimited
Streams: 0 of Unlimited
Consumers: 0 of UnlimitedIf you see the below instead then JetStream is not enabled
Creating an Object Store bucket
Just like you need to create streams before you can use them you need to first create an Object Store bucket
which outputs
Putting a file in the bucket
Putting a file in the bucket by providing a name
By default the full file path is used as a key. Provide the key explicitly (e.g. a relative path ) with --name
Listing the objects in a bucket
Getting an object from the bucket
Getting an object from the bucket with a specific output path
By default, the file will be stored relative to the local path under its name (not the full path). To specify an output path use --output
Removing an object from the bucket
Getting information about the bucket
Watching for changes to a bucket
Sealing a bucket
You can seal a bucket, meaning that no further changes are allowed on that bucket
Deleting a bucket
Using nats object rm myobjbucket will delete the bucket and all the files stored in it.
Last updated
Was this helpful?