AWS S3-将对象移到其他文件夹 [英] AWS S3 - Move an object to a different folder

查看:445
本文介绍了AWS S3-将对象移到其他文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用AWS开发工具包(最好是.Net)将对象移动到同一存储桶中的其他文件夹中?

Is there any way to move an object to a different folder in the same bucket using the AWS SDK (preferably for .Net)?

我能看到的所有建议都是复制到新位置"和删除原始位置"的建议(通过"CopyObjectRequest"和"DeleteObjectRequest"可以很容易地做到这一点),但是我只是想知道这是唯一的方法吗?

Searching around all I can see is the suggestion of Copy to new location and Delete of the original (Which is easy enough via "CopyObjectRequest" and "DeleteObjectRequest") however I'm just wondering is this the only way?

推荐答案

原来,您可以使用Amazon.S3.IO.S3FileInfo来获取对象,然后调用"MoveTo"方法来移动对象.

Turns out you can use Amazon.S3.IO.S3FileInfo to get the object and then call the "MoveTo" method to move the object.

S3FileInfo currentObject = new S3FileInfo(S3Client,Bucket,CurrentKey);
S3FileInfo movedObject = currentObject.MoveTo(Bucket,NewKey);

原来上面的"MoveTo"方法只是在幕后执行复制和删除操作:)

It turns out the above "MoveTo" method just performs a Copy and Delete behind the scenes anyway :)

有关更多信息:
https://docs .aws.amazon.com/sdkfornet/v3/apidocs/index.html?page = S3/TS3IOS3FileInfo.html& tocid = Amazon_S3_IO_S3FileInfo

For further information:
https://docs.aws.amazon.com/sdkfornet/v3/apidocs/index.html?page=S3/TS3IOS3FileInfo.html&tocid=Amazon_S3_IO_S3FileInfo

这篇关于AWS S3-将对象移到其他文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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