41414

Remove entire object directory tree using AWS-SDK

Question:

I'm using the aws-sdk, and I'm trying to delete an object with the #delete_object method, for example:

s3.delete_object(bucket: ENV["AWS_BUCKET"]), key: "images/123/myimage.png"))

How can I delete the route (that's "images/123") instead of only the .png file? I don't want empty "folders". I've tested adding only the first part of the route (s3.delete_object(bucket: ENV["AWS_BUCKET"]), key: "images/")) in the key parameter but doesn't work. Thanks!

Answer1:

The folder will auto delete when it's empty.

So if you delete your file and refresh the root folder, you will see that it's gone ! Aws-Magic =)

Recommend

  • Store PHPExcel files in Amazon S3
  • Alternating Item Style
  • Embed an image in a TreeNode
  • Rails 4, Carrierwave-aws, images uploaded to Amazon s3 locally, but not in production (Openshift)
  • Access Amazon s3 using http in angular2
  • Failed to start an instrument test from Firebase gcloud command line
  • Amazon s3 – 403 Forbidden with Correct Bucket Policy
  • AWS Cloudwatch not triggering on API calls
  • Give wx.StaticBitmap a transparent background? wxpython
  • Is creating a new version of an object in AWS S3 eventually consistent or read-after-write consisten
  • AWS Cognito- get user information with ID
  • Dynamically create AWS IoT topic
  • How can I selectively modify the src attributes of script tags in an HTML document using Perl?
  • Weighted round robin dns between 2 Cloudfront distributions
  • Can I monitor the progress of an S3 download using the AWS SDK?
  • Google datalab : how to import pickle
  • Rails 4.1 environment variables not reloading
  • How to create a custom Powershell operator?
  • Are there any issues with placing image as background on an extended JFrame?
  • Floated image with variable width and heading with background image
  • Android application: how to use the camera and grab the image bytes?
  • How to revert to previous XCode version?
  • Moving Android View and preventing onDraw to be called over and over again
  • How to get Eclipse Oxygen to run on Java 9
  • How to have background script and something similar to a default popup?
  • HTTP/2 streams vs HTTP/1.1 connections
  • Python urlparse: small issue
  • why overloaded new operator is calling constructor even I am using malloc inside overloading functio
  • Syntax for setting draggablecursor property in google maps api
  • Why value captured by reference in lambda is broken? [duplicate]
  • Adding a button at the bottom of a table view
  • Getting last autonumber in access
  • Get object from AWS S3 as a stream
  • How to get a value (ex: baseURL) in every Karate feature?
  • Delete MySQLi record without showing the id in the URL
  • GridView Sorting works once only
  • How to get icons for entities from eclipse?
  • Why joiner is not used after Sequence generator or Update statergy
  • Recursive/Hierarchical Query Using Postgres
  • UserPrincipal.Current returns apppool on IIS