file-store/pkg/file/meta/read.go

22 lines
369 B
Go
Raw Permalink Normal View History

package meta
import (
"bytes"
"encoding/json"
"io"
)
func ReadBytes(input io.ReadCloser) ([]byte, error) {
defer input.Close()
meta := &Meta{}
buf := &bytes.Buffer{}
if _, err := io.Copy(buf, input); err != nil {
return nil, err
}
bufBytes := buf.Bytes()
if err := json.Unmarshal(bufBytes, meta); err != nil {
return nil, err
}
return bufBytes, nil
}