Share Large Files Using Snow Leopard Services
Background
For a while, I've been using various things like Forklift Droplets, Dropzone and various other options as a place to quickly upload files to one of my web hosting accounts for sharing. I've also used the Dropbox public folder for this purpose, but never really got used to that method. This includes files that are too large to email, as well as images that I want to share on Twitter or a forum post somewhere.
The things I tried all worked with varying degrees of success, but after Snow Leopard came out I wanted the ability to accomplish the same thing with just a right-click. I've gone through several iterations of the script, and finally have something that I think is worthy of sharing.
There are a couple of things I wanted to accomplish:
- Right-click on a file anywhere in the finder to upload the file.
- Have the resulting URL automagically copied to my clipboard
Initially, I had issues with the second requirement, because Automator doesn't make it easy to get the filename for some unknown reason. There are all kinds of things to deal with the file itself, or the path, but it doesn't seem possible to easily get the name of the file. I ended up using a little Python tidbit to accomplish what was needed here.
Prerequisites
You need a web server setup that allows SSH access. If you're using a web host that doesn't allow SSH access, you're doing it wrong.
In order for the service we're going to build to work, you first need to have passwordless authentication set up between your computer and your webserver via SSH keys. This article looks like a fairly easy to follow set of instructions. There are myriad other tutorials for this, so just chug through some Google results until you find one that works for you.
Of course I anticipate that the target audience will already have this set up, so lets move on to the good stuff.
Instructions
You'll need to launch Automator, and choose Service as the starting point for your workflow.
The first step is to change the settings for what the service is used for to receive files or folders from the Finder, like this:
The first action you'll need to add is the "Get UNIX Paths of Files" action. Uncheck the one configuration box, like this. *Update:* This action isn't included by default. Check addendum 2 below for the AppleScript method.
You'll then add a Run Shell Script action. This is where the heavy lifting of file uploading is going to happen. Here's a screenshot, including the things you'll have to change from the default action settings:
- By default, the Pass input: dropdown will be set to stdin. You need to change this to "as arguments."
- Fill out the shell script to match the image, replacing the info with your user, domain name, and server path (of course). Some of this will already be filled in for you when you change the dropdown menu.
You then need to add a second Run Shell Script action. This is where we'll add a little Python magic:
- First, you need to change the Shell dropdown to /usr/bin/python instead of the default /bin/bash.
- Then, you'll change the Pass input: dropdown to "as arguments" like in the previous script.
- Then you'll need to enter the script as shown. Obviously you'll use your domain name between the quotes after filepath.
Finish it off with the Copy to Clipboard action, and you're all set. The resulting script will look something like this:
Now all you have to do is hit save, and give it a name like "share file" or whatever. It will then show up in the contextual Finder menu for any file in any location. A simple right click and you get a file that's uploaded and the URL gets put in your clipboard ready for easy sharing.
Addendum
I think I've figured out the Growl notification. If you want a growl notification when the process is complete, you can add something like this at the end of your workflow. I right-clicked on the "Run Shell Script" header and selected "ignore input." This requires that you installed growlnotify from the Extras folder on the Growl disk image.
Addendum 2
I realized that the Get Unix Paths step in here requires a plugin to be installed for Automator. The same thing can be accomplished without a plugin using the "Run AppleScript" action as shown below (to get the pretty colors, hit the little hammer icon after entering the text). Replace the first step with this one.

I've also uploaded an action that you can download and modify with your server information to make this all easier for you.











