Uploading Files to CloudApp from Alfred
Update: If you like, you can save yourself most of the configuration trouble and download the shortcut’s folder directly. I’ve put that up on github. The CloudApp icon is redistributed with permission.
This one takes advantage of the new feature in Alfred 0.9, Result Actions (Requires Powerpack). Actions can be performed on files that are selected using File Navigation or File Search. Basically they are like any other terminal shortcuts but with the ‘action’ checkbox checked, which tells Alfred to pass in the full file path as {query} when used in that context.
I used Aaron Russell’s cloudapp api wrapper gem, which made it really easy to create this script which basically adds an action to upload files selected in Alfred to CloudApp. I also use rb-appscript for the Growl notification AppleScript. You will need to install both of these gems to be able to use this script:
$ sudo gem install cloudapp_api rb-appscript
You may or may not need to use sudo depending on your setup.
Either paste the script shown below in a file somewhere or download it from this link.
Make sure you edit the script to set your CloudApp email address and password.
As usual, create a new shortcut in the ‘Terminal/Shell’ section in Alfred Preferences.

You can use whatever you want for the Title and Description. In this particular case, I didn’t really care about the Keyword as I don’t intend to use this shortcut directly.
In Command, point to the script you created/downloaded while passing the {query} in which Alfred will pass the file path:
~/bin/cloudapp_upload "{query}"
In addition, you can pass in one or two option to further customise the script’s behaviour:
- -p Create the drops as private.
- -m Mute the notification sound the script plays after finishing the upload.
Make sure you check both ‘Quotes’ and ‘Spaces’. After saving, tick both ‘Silent’ and ‘Action’.
That should be it. Now, if you navigate to a file (Fire up Alfred and start typing / or ~), or if you locate a file using find, hit CTRL to select the file and display the actions list, and you should see your brand new action at the bottom. Select it, patiently wait for the script to upload the file, and done! The URL of the file will also be copied to the clipboard straight away.

Here’s the script:
#!/usr/local/bin/ruby
require 'cloudapp_api'
require 'appscript'
# Set your CloudApp credentials:
EMAIL = 'your_email@example.com'
PASSWORD = 'yourpassword'
file = ARGV[0]
privacy = ARGV[1] == '-p' || ARGV[2] == '-p'
mute = ARGV[1] == '-m' || ARGV[2] == '-m'
exit if file.nil?
# Authenticate to CloudApp
client = CloudApp::Client.new
client.authenticate EMAIL, PASSWORD
# Upload file
drop = client.upload file, :private => privacy
# Create a Growl notification
include Appscript
growl = app("GrowlHelperApp")
notifications = ["CloudAppUpload"]
growl.register(
:as_application => "CloudAppUpload",
:all_notifications => notifications,
:default_notifications => notifications
)
growl.notify(
:with_name => "CloudAppUpload",
:title => "CloudApp Upload Succeeded",
:description => "The file '#{drop.name}' has been sucessfully uploaded to Cloudapp: #{drop.url}",
:application_name => "CloudAppUpload",
:icon_of_application => "Alfred"
)
# Play sound
exec 'afplay /System/Library/Sounds/Glass.aiff' unless mute
# Copy file URL to clipboard
IO.popen('pbcopy', 'r+') do |clipboard|
clipboard.puts "#{drop.url}"
end
You can respond to this article by replying on twitter or sending me an email.