s3iam_conf.go 540 B

1234567891011121314151617181920212223242526
  1. package filer
  2. import (
  3. "bytes"
  4. "github.com/chrislusf/seaweedfs/weed/pb/iam_pb"
  5. "github.com/golang/protobuf/jsonpb"
  6. "github.com/golang/protobuf/proto"
  7. "io"
  8. )
  9. func ParseS3ConfigurationFromBytes(content []byte, config *iam_pb.S3ApiConfiguration) error {
  10. if err := jsonpb.Unmarshal(bytes.NewBuffer(content), config); err != nil {
  11. return err
  12. }
  13. return nil
  14. }
  15. func ProtoToText(writer io.Writer, config proto.Message) error {
  16. m := jsonpb.Marshaler{
  17. EmitDefaults: false,
  18. Indent: " ",
  19. }
  20. return m.Marshal(writer, config)
  21. }