A few days ago I posted an entry about exposure, URL shorteners and how to start making your own. At the end of the post I wrote a way that I might build on top of what I had already created. I would somehow add the ability to upload a file to my server from my computer and automatically generate a short link to that file -- kinda like CloudApp. Today I did just that.

It took a few days with all that's been going on in my life -- but I managed to make a very crude working example that well -- works. I had a lot of help from Apple's Automator. This is a fantastic tool that is available on all Macs as far as I know. Through automator you can basically script certain actions in the OS so you don't have to do it manually every time. It takes some work, but it's a super powerful tool.

In my case, I wanted to upload a file from my computer and share it instantly via a custom shortened url. I completed this application in tiny, manageable pieces.

  1. Initially, I created an automator script that SCPs a file to my server once I drag it to a specific folder. Already the limitations had occurred to me. First, it's one folder. So that means every time I want to upload a file, I have to go to the folder and drag and drop my file. Also, what do I do when the file is there? It is physically removed from it's old location. Sure, I could copy it over and delete, but that requires extra steps.

    Folder Action Folder Action

    Service Service

  2. Then I got another idea of adding a Service to the OS instead. This means, instead of a folder action, this would be an actual service you run on the MacOS. What does that mean? Instead of having to drag and drop a file, I could just right-click on the file and hit "Send to RabIO" and the process would start from there.

    Right-Click Popup

  3. Through automator I set up the blueprint of what I wanted to happen. In the blueprint, I utilize a shell script that calls my external server and does the following: generate a file key; generate a custom short URL; upload file and produce confirmation.


  4. I'm able to right-click > Send to RabIO and wait for a popup message to confirm that the file has been uploaded and a short link has been copied into my clipboard.

    Short URL URL-Short

    Long URL URL-Long

Next steps

Right now the script runs and works as expected. Although I applied some initial security precautions to the application, I plan on locking it down further. I haven't written up a spec yet for the application, so I'll make it a little more organized down the road. The concept works and the nerd inside of me is pretty satisfied. Now onto the next thing!

comments powered by Disqus