问题
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