1
0
Fork 0
upl/credential.go

36 lines
846 B
Go
Raw Normal View History

2021-05-23 00:46:15 +08:00
package main
import (
"fmt"
"strings"
)
/* types */
type credential struct {
AccessKey string
SecretKey string
// Region is critical when signing requests.
Region string
// Endpoint is the base URL of the bucket, including the bucket name (in either the domain or path).
//
// Example:
// https://bucketname.s3.us-west-2.amazonaws.com
// http://my-minio.example.com/bucket-name
Endpoint string
// ACL is an optional canned ACL to set on objects
ACL string
// Prefix is a string to prepend to object keys
Prefix string
}
func (cred credential) validate() error {
if strings.HasSuffix(cred.Endpoint, "/") {
return fmt.Errorf("%w: endpoint should not end with slash", errBadRequest)
}
if strings.HasPrefix(cred.Prefix, "/") {
return fmt.Errorf("%w: prefix should not start with slash", errBadRequest)
}
return nil
}