I have been using Linode’s object storage for a year now. Its been primarily used to serve image files for one of my projects. In comparison to its competitor’s offering, Linode’s object storage is definitely much affordable than what Google and Amazon are offering. In fact, Linode’s comparison shows the price difference is almost 900%.
Object storage technology provides an economical way to serve static files like images and even HTML files. It also greatly reduces the load on the server and even helps reduce bandwidth consumption.
But being a latecomer to this space, Linodes’s object storage is still in its early stages of development and is not user-friendly for beginners. But since it’s based on Amazon’s AWS technology, it pretty much uses the same ways of interesting with the objects.
It took me a few days to learn all about Linode’s object storage. The learning curve isn’t that steep however, the lack of proper documentation by Linode is a big obstacle in the learning process.
A few days back, I decided to delete one of the storage buckets which had more than 20,00,000 objects. It’s only when I tried to delete the bucket, I came to know that the bucket has to be emptied before it can be deleted.
Deleting that amount of files was certainly not possible with Linodes object storage’s web interface as it allows to delete only one object at a time. So I had to move to python to empty the bucket.
However, with Linode’s object storage, you have to retrieve the list of objects in the bucket or container first. And that too is limited to 1000 objects per instance. So you can only retrieve 1000 objects and delete them. Which should take around 5 seconds. Well, this seems to be one of the major demerits of object storage technology, at least with Linode’s offering.
How to Empty all Files in Linode’s Object Storage Bucket and Delete it
If you need to know how to empty a Linode object storage bucker or delete all the files in it. Here’s how you can do so.
Since I was using python, I chose to use the Boto3 library to interact with Linodes object storage. You can use the following code by replacing it with your bucket access credentials. However, keep in mind that it might take from minutes to hours depending on the number of objects in the bucket. For me, it took more than 12 hours to delete all the 20,00,000 objects.
s3 = boto3.resource('s3',
aws_secret_access_key='SECRET ACCESS KEY')
bucket = s3.Bucket('BUCKET NAME')
REGION NAME: us-east-1
ENDPOINT URL : https://us-east-1.linodeobjects.com
The above details will differ according to the region you chose.
You can run the above code and wait while it empties the bucket. Then you can go ahead and delete the bucket from Linode’s web interface for object storage.
Last but not the least, if you have a better way to delete files by bulk with Linode’s object storage. Do let me know through the comments below.