MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / getClient

Method getClient

drivers/s3/util.go:50–82  ·  view source on GitHub ↗
(clientType int)

Source from the content-addressed store, hash-verified

48)
49
50func (d *S3) getClient(clientType int) *s3.S3 {
51 client := s3.New(d.Session)
52 if clientType == ClientTypeLink && d.CustomHost != "" {
53 client.Handlers.Build.PushBack(func(r *request.Request) {
54 if r.HTTPRequest.Method != http.MethodGet {
55 return
56 }
57 //判断CustomHost是否以http://或https://开头
58 split := strings.SplitN(d.CustomHost, "://", 2)
59 if utils.SliceContains([]string{"http", "https"}, split[0]) {
60 r.HTTPRequest.URL.Scheme = split[0]
61 r.HTTPRequest.URL.Host = split[1]
62 } else {
63 r.HTTPRequest.URL.Host = d.CustomHost
64 }
65 })
66 }
67 if clientType == ClientTypeDirectUpload && d.DirectUploadHost != "" {
68 client.Handlers.Build.PushBack(func(r *request.Request) {
69 if r.HTTPRequest.Method != http.MethodPut {
70 return
71 }
72 split := strings.SplitN(d.DirectUploadHost, "://", 2)
73 if utils.SliceContains([]string{"http", "https"}, split[0]) {
74 r.HTTPRequest.URL.Scheme = split[0]
75 r.HTTPRequest.URL.Host = split[1]
76 } else {
77 r.HTTPRequest.URL.Host = d.DirectUploadHost
78 }
79 })
80 }
81 return client
82}
83
84func getKey(path string, dir bool) string {
85 path = strings.TrimPrefix(path, "/")

Callers 1

InitMethod · 0.95

Calls 1

SliceContainsFunction · 0.92

Tested by

no test coverage detected