Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

I can't find how to delete multiple objects at once using the ruby aws sdk, in the doc they have a code example on how to delete a folder that contains files :

# batch operations, delete objects in batches of 1k

bucket.objects(prefix: '/tmp-files/').delete

What am looking for is, providing files keys and delete them at once, something like this :

    bucket.objects(keys: [





Any idea?

1 Answer

0 votes
by (44.4k points)

You can use delete_objects As the documentation example:


  delete: { # required

    objects: [ # required


        key: "ObjectKey", # required

        version_id: "ObjectVersionId",



    quiet: false,


  mfa: "MFA",

  request_payer: "requester", # accepts requester


so in your example:



  objects: [

   {key: 'avatars/0b722c42-4003-42cc-887c-b820cad3aed9/avatar1.png'},






Related questions

Browse Categories