How can I delete all versions of a file in a bucket
I have created a local version-enabled bucket and when I upload a file it creates two versions of the file (2 times the size of the file is allocated). But when I delete it just deletes one version. When I delete the file, as far as I could understand it just creates a delete flag, but the two files remain there. How can I, using the API or command line, delete all versions of a file in order to save space. I know that there are some Lifecycle policies that I can use but I did not figure out yet how to use it properly.
Hi @fsc7, There's actually no single command or API that will delete all the versions of an object, in line with AWS spec. You can write a simple script, though, with either command line or any language SDK, that will first ListObjectVersions and then loop through and delete every version you'd like with DeleteObject and the VersionId param. Hope this helps!