Simpler Sharing

The Faster and Nicer Way to Share Direct Dropbox Links

Michael Delcour
Technological Simplicity

--

by Michael Delcour

As a follow up to my recent article on how to make file sharing easier on recipients, I wanted to show you how I streamline the process for making Dropbox links. It might seem like a bit of a hassle, but for me, making dozens of shared links a day for clients, it is a serious time saver. The caveats: my method requires a Mac and the application Keyboard Maestro. There are cetainly other ways to accomplish the same objective, so this article can at lest be starting point for those on Windows.

First, the problem: Dropbox links are gangly and take users to a landing page instead of just directly download the file. This is how it works: Dropbox integrates with the Mac Finder, so that you can alt-click a document and a popup will allow you to “Share Dropbox Link”.

This will copy the file’s link, which you can then paste into a document. Again, the issue is that the link takes you to the Dropbox page. For my client’s ease, I would rather have the link automatically download the file.

The mechanics of Dropbox’s links are pretty straight forward. By default, the link will have a “0” (zero) at the end of it — this is what leads to the Dropbox page. If you change that “0” to a “1”, the link will instead download the file automatically without stopping at the web page. Much easier!

The only other issue I have with the process is that the Dropbox are often very long and complex. I would much rather use a service like bitly to shorten the link to a reasonable length. So, the trick is coming up with some sort of script that will take the original Dropbox link, replace the “0” with a “1”, send that new link to bitly to be shortened, and then paste the new link.

My method involves using Apple’s Automator program to create a workflow. The first action is “Get Contents of Clipboard”.

The second action is “Run Shell Script”. You’ll want to pass the input as arguments with the following commands (they will remove the “0” from the Dropbox link and replace it with a “1”):

a=$1
echo “${a%=*}”=1

The third action will be “Copy to Clipboard.”

The fourth action will take care of shortening the link. You’ll use the “Run AppleScript” action here with the following code. The first part of the code calls for your Bitly login ID and API Key, which you will need to add based on your account.

set my_Login to “[YOUR_LOGIN]”
set my_API_Key to “[YOUR_API_KEY]”
if my_API_Key is equal to “” then
return “bit.ly now requires you to have an account and to specify your login and API key. Please set these at the top of the /bitly snippet. To make the Internet Productivity Group editable, select it and choose File -> Duplicate, then delete the original read-only group.”
end ifset the ClipURL to (the clipboard as string)ignoring case
if ((characters 1 through 4 of ClipURL as string) is not “http”) then
return “Malformed URL.”
else
set the EncodedClipURL to urlencode(ClipURL) of me
set curlCMD to ¬
“curl — stderr /dev/null \”http://api.bit.ly/v3/shorten?format=txt&login=" & my_Login & “&apiKey=” & my_API_Key & “&uri=” & EncodedClipURL & “\””
— Run the script and get the result:
set tinyURL to (do shell script curlCMD)
return tinyURL
end if
end ignoring
on urlencode(theText)
set theTextEnc to “”
repeat with eachChar in characters of theText
set useChar to eachChar
set eachCharNum to ASCII number of eachChar
if eachCharNum = 32 then
set useChar to “+”
else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then
set firstDig to round (eachCharNum / 16) rounding down
set secondDig to eachCharNum mod 16
if firstDig > 9 then
set aNum to firstDig + 55
set firstDig to ASCII character aNum
end if
if secondDig > 9 then
set aNum to secondDig + 55
set secondDig to ASCII character aNum
end if
set numHex to (“%” & (firstDig as string) & (secondDig as string)) as string
set useChar to numHex
end if
set theTextEnc to theTextEnc & useChar as string
end repeat
return theTextEnc
end urlencode

The fifth and final action will be another “Copy to Clipboard”. Save the workflow. Now, what makes this whole project worthwhile is attaching this workflow to a keyboard shortcut using Keyboard Maestro. In my case, I use a combination of “shift-command-V”. In Keyboard Maestro, all you need to do is create a simple macro that executes the workflow you just created and then pastes the result.

Now, whenever you make a Dropbox link from a file in Finder and then paste using the shortcut you created (shift-command-V, in my case), a neat and tidy link will appear. When the recipient clicks on it, the file will be automatically downloaded to their computer. The setup might not be easy, but the payoff can be huge, especially for your recipients.

To demonstrate the result, here is direct download link (created using the above method) to a sample Automator workflow to get you started: http://bit.ly/1QAdAWj

Enjoy! Please email me or comment with any questions!

--

--

Michael Delcour
Technological Simplicity

Creatively and efficiently solving problems through creativity, technology, collaboration, and experience.