Files
cloudpods/vendor/github.com/ks3sdklib/aws-sdk-go/service/s3/service.go
2025-09-24 17:20:31 +08:00

71 lines
1.8 KiB
Go

// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
package s3
import (
"github.com/ks3sdklib/aws-sdk-go/aws"
"github.com/ks3sdklib/aws-sdk-go/internal/protocol/body"
"github.com/ks3sdklib/aws-sdk-go/internal/signer/v2"
"github.com/ks3sdklib/aws-sdk-go/internal/signer/v4"
"strings"
)
// S3 is a client for Amazon S3.
type S3 struct {
*aws.Service
}
// Used for custom service initialization logic
var initService func(*aws.Service)
// Used for custom request initialization logic
var initRequest func(*aws.Request)
// New returns a new S3 client.
func New(config *aws.Config) *S3 {
service := &aws.Service{
Config: aws.DefaultConfig.Merge(config),
ServiceName: "s3",
APIVersion: "2006-03-01",
}
service.Initialize()
// Handlers
if service.Config.SignerVersion == "V4" || service.Config.SignerVersion == "V4_UNSIGNED_PAYLOAD_SIGNER" {
service.Handlers.Sign.PushBack(v4.Sign)
} else {
service.Handlers.Sign.PushBack(v2.Sign)
}
service.Handlers.Build.PushBack(body.Build)
service.Handlers.Unmarshal.PushBack(body.UnmarshalBody)
service.Handlers.UnmarshalMeta.PushBack(body.UnmarshalMeta)
service.Handlers.UnmarshalError.PushBack(body.UnmarshalError)
// Run custom service initialization if present
if initService != nil {
initService(service)
}
return &S3{service}
}
// newRequest creates a new request for a S3 operation and runs any
// custom request initialization.
func (c *S3) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {
r := aws.NewRequest(c.Service, op, params, data)
if r.Config.DomainMode {
r.HTTPRequest.URL.Path = strings.Replace(r.HTTPRequest.URL.Path, "/{Bucket}", "", -1)
if r.HTTPRequest.URL.Path == "" {
r.HTTPRequest.URL.Path = "/"
}
} else {
updateHostWithBucket(r)
}
// Run custom request initialization if present
if initRequest != nil {
initRequest(r)
}
return r
}