gpt4 book ai didi

amazon-web-services - AWS S3 上传的文件未显示

转载 作者:IT王子 更新时间:2023-10-29 01:53:57 26 4
gpt4 key购买 nike

我正在使用 golang sdk 将文件上传到 amazon S3 上的存储桶。响应没有给出错误并且文件上传成功。我的问题是当我在上传新 .jpg 文件的同一区域中列出存储桶的对象时。我得到相同的文件列表,但没有新文件添加到存储桶中。我不知道我做错了什么。这是我用来列出存储桶内对象的代码。

input := &s3.ListObjectsInput{
Bucket: aws.String("Bucket Name"),
}
result2, err := svc.ListObjects(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case s3.ErrCodeNoSuchBucket:
fmt.Println(s3.ErrCodeNoSuchBucket, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
log.Println("Bucket List", result2)

最佳答案

s3 是最终一致的,可能不会显示最近写入列表的对象,即使来自同一区域内也是如此:

Amazon S3 achieves high availability by replicating data acrossmultiple servers within Amazon's data centers. If a PUT request issuccessful, your data is safely stored. However, information about thechanges must replicate across Amazon S3, which can take some time, andso you might observe the following behaviors:

A process writes a new object to Amazon S3 and immediately lists keyswithin its bucket. Until the change is fully propagated, the objectmight not appear in the list.

A process replaces an existing object and immediately attempts to readit. Until the change is fully propagated, Amazon S3 might return theprior data.

A process deletes an existing object and immediately attempts to readit. Until the deletion is fully propagated, Amazon S3 might return thedeleted data.

A process deletes an existing object and immediately lists keys withinits bucket. Until the deletion is fully propagated, Amazon S3 mightlist the deleted object.

参见 S3 developer guide

有一个轮询 Go AWS API 调用“func (*S3) WaitUntilObjectExists”,它一直在寻找文件,直到它出现或发生超时

更新 s3 is now strongly consistent感谢@Tensiba 指出这一点!

Amazon S3 provides strong read-after-write consistency for PUT andDELETE requests of objects in your Amazon S3 bucket in all AWSRegions. This behavior applies to both writes to new objects as wellas PUT requests that overwrite existing objects and DELETE requests.In addition, read operations on Amazon S3 Select, Amazon S3 accesscontrols lists (ACLs), Amazon S3 Object Tags, and object metadata (forexample, the HEAD object) are strongly consistent.

关于amazon-web-services - AWS S3 上传的文件未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51408511/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com