检查成功的S3复制操作? [英] Checking for succesful S3 copy operation?

查看:105
本文介绍了检查成功的S3复制操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用亚马逊S3的Java API来实现移动操作。

I'm trying to implement a move operation using the Amazon S3 Java API.

我遇到的问题是,<一个href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/model/CopyObjectResult.html"相对=nofollow> CopyObjectResult 通过对象返回的<一个href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3Client.html#copyObject%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String%29"相对=nofollow> AmazonS3Client.copyObject 方法似乎并不有关于wiether操作成功与否的明确指标。

The problem I am having is that the CopyObjectResult object returned by the AmazonS3Client.copyObject method doesn't seem to have a clear indicator about wiether the operation was successful or not.

由于此操作,我将要删除的文件后,我想,以确保操作成功。

Given that after this operation I am going to be deleting a file, I'd want to make sure that the operation was successful.

有什么建议?

推荐答案

这是我落得这样做,

def s3 = createS3Client(credentials)
def originalMeta = s3.getObjectMetadata(originalBucketName, key)
s3.copyObject(originalBucketName, key, newBucketName, newKey)
def newMeta = s3.getObjectMetadata(newBucketName, newKey)

// check that md5 matches to confirm this operation was successful
return originalMeta.contentMD5 == newMeta.contentMD5

请注意,这是Groovy的code,但它是非常类似于如何在Java code会的工作。

Note that this is Groovy code, but it is extremely similar to how the Java code would work.

我不喜欢做两个额外的操作,以检查元数据,因此,如果有无论如何要做到这一点更有效地让我知道。

I don't like having to make two additional operations to check the metadata, so if there is anyway to do this more efficiently let me know.

这篇关于检查成功的S3复制操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆