GetBytes is a convenience function to pull an object from this object store and return it as a byte slice.
(name string, opts ...GetObjectOpt)
| 847 | |
| 848 | // GetBytes is a convenience function to pull an object from this object store and return it as a byte slice. |
| 849 | func (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. |
| 864 | func (obs *obs) PutString(name string, data string, opts ...ObjectOpt) (*ObjectInfo, error) { |