android amazon sdk S3 putObject 的奇怪问题
当我使用亚马逊的 aws-android-sdk 时,我发现一件奇怪的事情。我的应用程序将一些文件放入存储桶,之后当我尝试从另一个设备获取该文件时 - 文件可能会消失(看起来可能是 15 次尝试中的 1 次)。但过了一段时间(不长) - 文件出现,我可以接受它。我的代码在这里:
final AWSCredentials credentials = new BasicAWSCredentials(sharedAccessKey,sharedSecretAccessKey);
client = new AmazonS3Client(credentials);
final PutObjectResult result = client.putObject(bucket, key, localFile);
之后我检查结果不为空并向另一个设备发送通知以获取该文件。为什么我在发送和可用性之间看到这种延迟?有什么解决方法吗?
更新:我的另一部手机是 iPhone,我尝试使用预先签名的 url 下载文件,
谢谢
I found one strange thing when I am use amazon's aws-android-sdk. My application put some files to bucket and after this when I try to get this file from another device - file can be gone (it appears may be 1 of 15 tries). But after some time(not long) - file appears and I can take it. My code here:
final AWSCredentials credentials = new BasicAWSCredentials(sharedAccessKey,sharedSecretAccessKey);
client = new AmazonS3Client(credentials);
final PutObjectResult result = client.putObject(bucket, key, localFile);
After this I check that result not null and send notification to another device to get this file. Why i see this delay between sending and availability? What is workaround for this ?
update: My another phone is iPhone where i try download file using presigned url
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它被称为“最终一致性”,对此您无能为力,只能等待。我通常发现将对象上传到 S3,然后立即检查它是否存在(例如在 100 毫秒内)通常会失败。等待几秒钟通常没问题,但有时事情似乎会变得有点棘手。
下面有更多详细信息。美国标准,因为它存储左右海岸的数据,在这方面可能会更糟。
http://shlomoswidler.com/2009/12/read -after-write-consistency-in-amazon.html
Its called 'eventual consistency' and there is not much you can do about it, other then wait. I generally find that uploading an object to S3, then immediately checking if its there (like within 100ms) will often fail. Waiting a few seconds is usually fine, but sometimes things can get a little sticky it seems.
More detail below. US Standard, since it stores data on left and right coasts can e worse in this regard.
http://shlomoswidler.com/2009/12/read-after-write-consistency-in-amazon.html