Learning to Code with Ruby
Last week I got sucked into a small coding project. I wanted a quick way to upload files to AWS S3. S3 acts like a FTP file server. But traditional upload methods like SFTP aren’t allowed. This makes the service tricky to use from the command line.
I wanted a simple tool that I could use in three different ways:
- Directly from the command line.
- Inside of an Automator workflow “run shell scrip” action. This will provide a right-click upload action in the Finder
- From a shell script action in Hazel. Files that match a rule can also be uploaded.
There are several file transfer program that have a graphical interface. Filezilla doesn’t support the S3 protocol. The built-in uploader in Hazel also doesn’t speak S3. Cyberduck is able to connect to S3 and Rackspace Cloud Files. But it’s not scriptable and must be used manually.
After some research I found a library for ruby called “Fog.” It provides access to S3 and Cloud Files with the same code base. This also meant I needed to get more than a passing familiarity with the language.
This is something I’ve playing with off-and-on over the last week. I’ve come up with the start of a project I’m calling AWS-upload. There’s even a GitHub project page for it now. It’s still rough. Really rough. It’s also not working as of this post. The code is split among several files. I plan on integrating them in the future. I’ll need to if I want a working program. This way lets me explore different aspects of the program in small chunks.
I’ll be making more code-related posts as I work on it. I’m also learning ruby as I go. Wish me luck!