Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6898871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:21:02+00:00 2026-05-27T07:21:02+00:00

I know that s3 does not really support the folder concept. Copy/Delete all files

  • 0

I know that s3 does not really support the folder concept. Copy/Delete all files should work. But maybe somebody knows a simpler way to do this (and I just haven’t found it int the SDK)

Update/Solution:

The following code is working for me.

       using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client("xxx",
                                                              "yyy"))
        {

            ListObjectsRequest listRequest = new ListObjectsRequest();
            listRequest.WithBucketName("ytimusic")
                .WithPrefix("M" + oldOWnerId.ToString()+"/");


            // get all objects inside the "folder"
            ListObjectsResponse objects = client.ListObjects(listRequest);
            foreach (S3Object s3o in objects.S3Objects)
            {

                // get the acl of the object
                GetACLRequest aclRequest = new GetACLRequest();
                aclRequest.WithBucketName("thebucket")
                    .WithKey(s3o.Key);
                GetACLResponse getAclResponse = client.GetACL(aclRequest);


                // copy the object without acl
                string newKey = s3o.Key.Replace(oldOWnerId.ToString(), newOwnerId.ToString());
                CopyObjectRequest copyRequest = new CopyObjectRequest();
                copyRequest.SourceBucket = "thebucket";
                copyRequest.DestinationBucket = "thebucket";
                copyRequest.WithSourceKey(s3o.Key)
                .WithDestinationKey(newKey);
                S3Response copyResponse = client.CopyObject(copyRequest);

                // set the acl of the newly created object
                SetACLRequest setAclRequest = new SetACLRequest();
                setAclRequest.WithBucketName("ytimusic")
                    .WithKey(newKey)
                    .WithACL(getAclResponse.AccessControlList);

                SetACLResponse setAclRespone = client.SetACL(setAclRequest);

                DeleteObjectRequest deleteRequest = new DeleteObjectRequest();
                deleteRequest.WithBucketName("thebucket")
                    .WithKey(s3o.Key);

                DeleteObjectResponse deleteResponse = client.DeleteObject(deleteRequest);

            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:21:02+00:00Added an answer on May 27, 2026 at 7:21 am

    S3 doesn’t support neither renaming nor folders, so you actually need to process each file individually by creating a copy with the desired name and deleting the original. To do this with the .NET SDK I’m afraid there is no easier way than listing all files in the directory, and renaming each using CopyObject+DeleteObject. Also, be aware that according to the docs (http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?RESTObjectCOPY.html) the copy operation does not preserve the ACL, so if the moved files are public you need to explicitly mark the copies as public as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that XSLT does not work in procedural terms, but unfortunately I have
I know that mySQL 5.x does not support INTERSECT, but that seems to be
I know that VPC does not officially support Linux, but I was wondering if
So in the meanwhile we know that double-checked-locking as is does not work in
I am curious about COM+, DCOM. I know that MSFT does not encourage you
I know that an interface does not have a body, just a method definition.
I know that being open source does not necessarily makes a program more/less secure
Does anyone know of an IDE for F# development that does not involve me
In Oracle, this returns 03/01/2010. That does not make sense to me. Anybody know
Does anyone know there have any other way that (by not using json_encode and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.