所以我尝试克隆我的 S3 (Amazon S3) 帐户上的文件夹中的对象。但我想知道是否有一种方法可以做到这一点,而不必先将文件写入本地系统,然后将该文件上传回 S3?
最终我希望它能够完全递归地克隆给定存储桶中的文件夹和对象,但现在我一直坚持让它有效地克隆。
假设存储桶路径是 images.example.com/products/prodSku 在该 prodSku 文件夹中,我有一堆图像,我想将其复制到新文件夹
这是我到目前为止所拥有的。
(注意:这是用groovy编写的,但是如果你了解java,那是一样的)
try{
def s3os = restService.listObjects(bucket_name, sourcePrefix, null)
def s3o
for(def i in s3os){
s3o = get(bucket_name, i.key)
// i want to be able to do something like this, just putting the input stream
// back into s3. but i can't. from what i know now, i have to write the
// dataInputStream into a file locally, then use that file to create a new S3Object
// which is placed as the second argument in the putObject method
restService.putObject(destinationBucketName, s3o.dataInputStream)
}
}catch(S3ServiceException e)
{
println e
}
第一次发帖,格式有点乱,抱歉。
但任何帮助将不胜感激!
谢谢!
最佳答案
不确定 JetS3t API,但是 AWS SDK for Java确实提供了一个简单的copyObject方法
关于java - 如何使用 RestS3Service 克隆 Amazon S3 中的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5280030/