AWS S3 - Move an object to a different folder

Deadly 提交于 2020-08-22 12:11:37

问题


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

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?


回答1:


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);

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

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



来源:https://stackoverflow.com/questions/28830839/aws-s3-move-an-object-to-a-different-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!