« »

Add files to drop.io directly from the Finder

I’ve kind of haphazardly have been using drop.io for a while now and decided that the thing that’s really been holding me back from using it was the web interface. It really broke my flow to have to go to the website when I’m looking at a file in the Finder. It’d be so much easier to take care of that directly from the Finder with a contextual menu or something. So I spent an hour or so today hacking this together and figured I’d share an simple shell script to use with Automator to add a “Send to drop.io” item to the Finder’s file contextual menu.

First things first, you need a drop.io account (“drop”) and the drop’s authentication token. The token can be found in the Details pane of the Settings (last item under “Drop Details”, just search for “token”). Now that you’ve got these two pieces of information, open Automator and create a new workflow.

Next, you’ll need an API key. Previously, I had posted my own since I didn’t think it’d matter much, but it’s probably a good idea to get your own. You can get an API key fairly easily from drop.io’s API website. Simply create a new account and use that key.

This workflow will have just two stages. First, get the selected files from the Finder. Second, run a shell script. Here’s a quick screenshot:

Drop.io+Automator

Note that the shell is bash (the script below is written for the bash shell, but may work in similar shells and can be rewritten for others easily) and “Pass input” is set to “as arguments” (note that this isn’t the default so you will have to change it). Now, copy and paste the following script into the shell script text field:

DROPNAME=":your_drop_name:"
TOKEN=":your_auth_token:"
APIKEY=":your_api_key:"

for f in "$@"
do
cd `dirname "$f"`
FILE=`basename "$f"`
curl -F version=1.0 -F token=$TOKEN -F api_key=$APIKEY -F drop_name=$DROPNAME -F "file=@$FILE" http://assets.drop.io/upload
done

Now that the script is in place, change the DROPNAME variable to your drop’s name (my drop is located at http://drop.io/Grayson so the drop name is “Grayson”; the line would then read: DROPNAME="GRAYSON") and put in the auth token that you looked up earlier in TOKEN. In addition, put in the API key that you’ve registered earlier.

Once all of the information is in the appropriate place, go to Automator’s File menu and select “Save as Plug-in…”. Select it to be a Finder plugin, save, and you should be ready to start sending files to drop.io. The menu item will appear in the More->Automator menu when you right-click/control-click on a file in the Finder.

2 comments on “Add files to drop.io directly from the Finder”

lee:

March 2nd, 2009 at 5:57 pm

Wow. This is pretty neat. I have ignored automator for long enough. I do stuff manually in the shell all the time and didn’t realize making a finder plugin is this simple.

One thing, you posted your API key here. Might want to delete that and have users get their own.

Grayson:

March 2nd, 2009 at 6:25 pm

I find that I’m using Automator more and more for this type of plugin support. It’s not as quick as I’d like, but it works and is really easy.

I’ve also removed the API key. I figured it really didn’t matter and API keys are only semi-hidden/private anyway. However, it’s really easy to get one so I updated the post to advise people to get their own.

Leave a Reply