aboutsummaryrefslogtreecommitdiff
path: root/weed/filer/s3iam_conf.go
blob: 92387fb09be0a12f4294324484bce7bd9359835c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package filer

import (
	"bytes"
	"github.com/chrislusf/seaweedfs/weed/pb/iam_pb"
	"github.com/golang/protobuf/jsonpb"
	"io"
)

func ParseS3ConfigurationFromBytes(content []byte, config *iam_pb.S3ApiConfiguration) error {
	if err := jsonpb.Unmarshal(bytes.NewBuffer(content), config); err != nil {
		return err
	}
	return nil
}

func S3ConfigurationToText(writer io.Writer, config *iam_pb.S3ApiConfiguration) error {

	m := jsonpb.Marshaler{
		EmitDefaults: false,
		Indent:       "  ",
	}

	return m.Marshal(writer, config)
}