-
Notifications
You must be signed in to change notification settings - Fork 91
/
bucket_referer.go
58 lines (52 loc) · 1.58 KB
/
bucket_referer.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package cos
import (
"context"
"encoding/base64"
"encoding/xml"
"net/http"
)
type BucketPutRefererOptions struct {
XMLName xml.Name `xml:"RefererConfiguration"`
Status string `xml:"Status"`
RefererType string `xml:"RefererType"`
DomainList []string `xml:"DomainList>Domain"`
EmptyReferConfiguration string `xml:"EmptyReferConfiguration,omitempty"`
VerifySignatureURL string `xml:"VerifySignatureURL,omitempty"`
}
type BucketGetRefererResult BucketPutRefererOptions
func (s *BucketService) PutReferer(ctx context.Context, opt *BucketPutRefererOptions) (*Response, error) {
sendOpt := &sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?referer",
method: http.MethodPut,
body: opt,
}
resp, err := s.client.doRetry(ctx, sendOpt)
return resp, err
}
func (s *BucketService) GetReferer(ctx context.Context) (*BucketGetRefererResult, *Response, error) {
var res BucketGetRefererResult
sendOpt := &sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?referer",
method: http.MethodGet,
result: &res,
}
resp, err := s.client.doRetry(ctx, sendOpt)
return &res, resp, err
}
// Put空
func (s *BucketService) DeleteReferer(ctx context.Context) (*Response, error) {
sendOpt := &sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/?referer",
method: http.MethodPut,
optHeader: &struct {
Md5 string `header:"Content-Md5"`
}{
Md5: base64.StdEncoding.EncodeToString(calMD5Digest([]byte(""))),
},
}
resp, err := s.client.doRetry(ctx, sendOpt)
return resp, err
}