Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

AWS Scripts: [Python] Removing Invalid Characters in Object Names in Your S3 Bucket

Hey All!

This is my first post on this website so I thought I should make it a good one. I was working with my S3 bucket the other day from my Mac laptop and uploaded a few files without giving it any thought. Got home and jumped on my PC to download these files.. turns out I couldn’t download these files even though my permissions were correct to download them.

The error presented was “IOError: [Errno 22] invalid mode (‘wb’) or filename: ‘C:\\Users\\Dustin\Documents\Logs-12:22:13PM.txt'”

Naturally, I googled for why Errno 22 would be returned and it turns out the colon character is not allowed within a filename for a Windows machine, who would have thought?!

Even though I only had a few files with colons within the filename, I thought it might be helpful to create a Python Script using the Boto3 SDK to remove the colons so that I could actually edit them on my PC.

Below I’ve added the file with the appropriate comments explaining what it does.  I hope you get as much, if not more, use out of it as I have.

“rename-bad-objects-windows.py”

Detayl’s Repository 

Enjoy!

Rename Bad Objects in S3 for Future Download.


This post first appeared on Better Tech, Awesome Gadgets, please read the originial post: here

Share the post

AWS Scripts: [Python] Removing Invalid Characters in Object Names in Your S3 Bucket

×

Subscribe to Better Tech, Awesome Gadgets

Get updates delivered right to your inbox!

Thank you for your subscription

×