小编Ben*_*rno的帖子

由于没有此类主机错误,Amazon S3 无法调用 API

我正在尝试在 GoLang 中构建 Amazon S3 客户端,但在进行 API 调用时遇到问题。我收到一条错误消息,提示“没有这样的主机”,但我确信我提供的凭据是正确的。

定义一个结构体来保存客户端

// the Client struct holding the client itself as  well as the bucket.
type S3Client struct {
    S3clientObject s3.S3
    bucket string
}

// Initialize the client
func CreateS3Client() S3Client{
     S3clientCreate := S3Client{S3clientObject: Connect(), bucket: GetS3Bucket()}
     if (!CheckBuckets(S3clientCreate)) {
         exitErrorf("Bucket does not exist, try again.")
     }
     return S3clientCreate
}
Run Code Online (Sandbox Code Playgroud)

连接到存储桶

func Connect() s3.S3{
    // Initialize a session
    
    sess, err := session.NewSession(&aws.Config{
        Credentials: credentials.NewStaticCredentials("myCredentials", "myCreds", ""),
        Endpoint:    aws.String("myDomain"),
        Region:      aws.String("myRegion"),
    },
    )
    if …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 go bucket amazon-web-services

0
推荐指数
1
解决办法
4203
查看次数

标签 统计

amazon-s3 ×1

amazon-web-services ×1

bucket ×1

go ×1