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

问题描述

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

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

我遇到的问题是, CopyObjectResult 通过对象返回的 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复制操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 11:40