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

Method GetString

jetstream/object.go:1114–1126  ·  view source on GitHub ↗

GetString is a convenience function to pull an object from this object store and return it as a string.

(ctx context.Context, name string, opts ...GetObjectOpt)

Source from the content-addressed store, hash-verified

1112
1113// GetString is a convenience function to pull an object from this object store and return it as a string.
1114func (obs *obs) GetString(ctx context.Context, name string, opts ...GetObjectOpt) (string, error) {
1115 result, err := obs.Get(ctx, name, opts...)
1116 if err != nil {
1117 return "", err
1118 }
1119 defer result.Close()
1120
1121 var b bytes.Buffer
1122 if _, err := b.ReadFrom(result); err != nil {
1123 return "", err
1124 }
1125 return b.String(), nil
1126}
1127
1128// PutFile is convenience function to put a file into an object store.
1129func (obs *obs) PutFile(ctx context.Context, file string) (*ObjectInfo, error) {

Callers

nothing calls this directly

Calls 3

GetMethod · 0.95
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected