DZone
Cloud Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Cloud Zone > Quick Look at the New S3 Multi-Object Delete Funcitonality

Quick Look at the New S3 Multi-Object Delete Funcitonality

Jason Whaley user avatar by
Jason Whaley
·
Apr. 28, 12 · Cloud Zone · Interview
Like (0)
Save
Tweet
4.59K Views

Join the DZone community and get the full member experience.

Join For Free

I’m a little late posting about this one, but it is still a cool feature

AWS just keeps pumping out features. One of the latest was multi object delete in s3.

Previously, if you wanted to delete multiple objects within an s3 bucket, each delete operation had to be contained in a single API requests… which quite honestly is slow and clunky. If you wanted to delete 5,000 objects you are going to have to make 5,000 API calls.

This is no more with the addition of multi-object delete. This feature was pretty quickly incorporated in to boot as well. Here is how simple it is. Let’s say I wanted to delete all objects that ended in “6” within a given bucket. I can now just pass the result of a list comprehension to the Bucket delete_keys method in a very concise and pythonic manner.

>>> import boto
>>> s3 = boto.connect_s3()
>>> bucket = s3.get_bucket("basementcoders.logging")
>>> result = bucket.delete_keys([key.name for key in bucket if key.name[-1] == '6'])
>>> result.deleted
[<Deleted: basementcoders.downloads2011-01-30-21-37-29-09929716CC5526B6>, <Deleted: basementcoders.downloads2011-01-16-17-19-55-
E50B56C60B99F316>]

The result reference I get back and report the keys that were actually deleted and what keys resulted in errors. All of this happens with a single API request.

AWS

Published at DZone with permission of Jason Whaley, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Submit a Post to DZone
  • Password Authentication: How to Correctly Do It
  • Java Hashtable, HashMap, ConcurrentHashMap: Performance Impact
  • Don't Underestimate Documentation

Comments

Cloud Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo