MCPcopy
hub / github.com/nats-io/nats.go / GetBytes

Method GetBytes

object.go:849–861  ·  view source on GitHub ↗

GetBytes is a convenience function to pull an object from this object store and return it as a byte slice.

(name string, opts ...GetObjectOpt)

Source from the content-addressed store, hash-verified

847
848// GetBytes is a convenience function to pull an object from this object store and return it as a byte slice.
849func (obs *obs) GetBytes(name string, opts ...GetObjectOpt) ([]byte, error) {
850 result, err := obs.Get(name, opts...)
851 if err != nil {
852 return nil, err
853 }
854 defer result.Close()
855
856 var b bytes.Buffer
857 if _, err := b.ReadFrom(result); err != nil {
858 return nil, err
859 }
860 return b.Bytes(), nil
861}
862
863// PutString is convenience function to put a string into this object store.
864func (obs *obs) PutString(name string, data string, opts ...ObjectOpt) (*ObjectInfo, error) {

Callers

nothing calls this directly

Calls 3

GetMethod · 0.95
BytesMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected