GetBytes is a convenience function to pull an object from this object store and return it as a byte slice.
(ctx context.Context, name string, opts ...GetObjectOpt)
| 1092 | |
| 1093 | // GetBytes is a convenience function to pull an object from this object store and return it as a byte slice. |
| 1094 | func (obs *obs) GetBytes(ctx context.Context, name string, opts ...GetObjectOpt) ([]byte, error) { |
| 1095 | result, err := obs.Get(ctx, name, opts...) |
| 1096 | if err != nil { |
| 1097 | return nil, err |
| 1098 | } |
| 1099 | defer result.Close() |
| 1100 | |
| 1101 | var b bytes.Buffer |
| 1102 | if _, err := b.ReadFrom(result); err != nil { |
| 1103 | return nil, err |
| 1104 | } |
| 1105 | return b.Bytes(), nil |
| 1106 | } |
| 1107 | |
| 1108 | // PutString is convenience function to put a string into this object store. |
| 1109 | func (obs *obs) PutString(ctx context.Context, name string, data string) (*ObjectInfo, error) { |