canadaduane

Dropbox Short Links Workflow

52 posts in this topic

For any file in your Dropbox folder, this workflow shows the dropbox short link URL (e.g. http://db.tt/1LkWGVJF) and copies the link to the clipboard (Cmd+Shift+D):

 

1. Select a file in Finder (must be a file within your Dropbox folder, e.g. ~/Dropbox/Photos/MyPhoto1.jpg)

2. Press Command+Shift+D

3. Authorize the workflow to use the Dropbox API (only if this is the first time)

4. The shortened link pops up and is copied to the clipboard.

 

It uses OAuth in the background to connect to Dropbox so you can authorize the Alfred 2 Workflow without storing passwords insecurely. For those who are interested, it starts a Ruby-based local web server using Sinatra which is then opened in the default browser. You can authorize the Dropbox app in your browser, and then the local server shuts itself down. Once authenticated, you don't need to do this step again.

 

Once connected via OAuth, this workflow has the potential to do a lot of things with Dropbox, but currently only queries the dropbox service for shortened URLs. This method (using OAuth/dropbox) has the advantage that any file in your Dropbox folder can be shared, not just those in the "public" directory (a deprecated method of accessing dropbox files).

 

The downloadable workflow itself is here (on dropbox, naturally):

 

http://db.tt/A3eZqMAr (new version, fixes direct linking to folders)
 
And the github repository is here:
 

Duane

Share this post


Link to post

Have been waiting for someone to build this workflow - thanks.

 

One request - the flow returns only the short link. I'd sometimes prefer to not generate the short link (only 8 characters), but instead get the longer link. Would that be feasible? 

 

Thanks again

Share this post


Link to post

The download is huge (compared to other workflows) with a lot of files. Is that right?

 

Yeah, it comes with several Ruby gems as well as images for the HTML "success" page. Some of it could probably be trimmed down, but in today's bandwidth I didn't think 3MB would be an issue.

Share this post


Link to post

Have been waiting for someone to build this workflow - thanks.

 

One request - the flow returns only the short link. I'd sometimes prefer to not generate the short link (only 8 characters), but instead get the longer link. Would that be feasible? 

 

Thanks again

 

Yes, the full URL is supported by the dropbox-api ruby gem. Maybe I could create a Command+Shift+Ctrl+D alternative for the full link?

Share this post


Link to post

Maybe I could create a Command+Shift+Ctrl+D alternative for the full link?

 

Reload the original download and you should get a new Command+Shift+Ctrl+D hotkey for a direct URL link to the file.

 

I also trimmed the file a bit, so it's under 2 MB now :)

 

Duane

Share this post


Link to post

Reload the original download and you should get a new Command+Shift+Ctrl+D hotkey for a direct URL link to the file.

 

Fantastic - works fine and addresses my paranoia the short link could be guessed

Share this post


Link to post

Is there a way this could grab a link for folders as well? 

 

Thanks

 

Good call. I hadn't noticed that the underlying dropbox-api library didn't offer support for this. I fixed it and sent a pull request to the original library.

 

In the meantime, the workflow has been updated and re-downloading the link above should give you a version that supports getting links for folders as well.

 

Duane

sphardy likes this

Share this post


Link to post

Good call. I hadn't noticed that the underlying dropbox-api library didn't offer support for this. I fixed it and sent a pull request to the original library.

 

In the meantime, the workflow has been updated and re-downloading the link above should give you a version that supports getting links for folders as well.

 

Duane

 

It seems short links to folders are working, but not the full links - nothing is returned

Share this post


Link to post

I get Only a limited set of users can receive access tokens while this app is in development mode. Any ideas?

 

I've applied for a "production" license for the app at Dropbox. I'm not sure what they'll do--I've never applied for one before.

 

If you want to access it in the meantime, you can get your own development key for the app, and then replace the dropbox_app_key/dropbox_app_secret in the bundle_settings.yml file in the workflow's directory.

Share this post


Link to post

It seems short links to folders are working, but not the full links - nothing is returned

 

 
Here's what I get in the Console.app log:
 
Alfred Workflow[22033]: Creating a link for a directory is not allowed. (Dropbox::API::Error) [query: /Users/duane/Dropbox/Books]
 
:(

Share this post


Link to post
 
Here's what I get in the Console.app log:
 
Alfred Workflow[22033]: Creating a link for a directory is not allowed. (Dropbox::API::Error) [query: /Users/duane/Dropbox/Books]
 
:(

 

Wow - how weird? Why would short links be OK but not the full links to which they redirect?

Share this post


Link to post

I've applied for a "production" license for the app at Dropbox. I'm not sure what they'll do--I've never applied for one before.

 

If you want to access it in the meantime, you can get your own development key for the app, and then replace the dropbox_app_key/dropbox_app_secret in the bundle_settings.yml file in the workflow's directory.

 

BTW, the workflow has been approved for "production" by Dropbox so as many people as would like to use it, should be able to now. I had to remove the dropbox icon from the workflow (at least for approval--my personal copy uses the logo anyway :) Here are the branding guidelines:

 

https://www.dropbox.com/developers/reference/branding

 

Here is the "approved" workflow with changed icon (also, renamed to "Dropbox Quick Links"):

 

 
Duane

Share this post


Link to post

Wow - how weird? Why would short links be OK but not the full links to which they redirect?

 

Ok, I figured it out. The API library was asking for a "media" link in the case of direct URLs, and directories are not considered "media". 

 

The latest at http://db.tt/A3eZqMAr should fix it.

 

Duane

sphardy likes this

Share this post


Link to post

Ok, I figured it out. The API library was asking for a "media" link in the case of direct URLs, and directories are not considered "media". 

 

The latest at http://db.tt/A3eZqMAr should fix it.

 

Duane

 

Quick test shows this appears to be fixed - thanks again

Share this post


Link to post

Hi,

 

I am running two different copies of Dropbox (one personal, one for work). Is there a way for this to support both of them? I use this functionality a whole lot and this workflow will make it much easier. Thanks!

Share this post


Link to post

Any way non-Dropbox files could be copied to a configurable Dropbox directory? Being able to easily share any file would be pretty great. Thanks!

 

It's certainly possible. I think to do it right, we'd need a configuration page or something... some way to indicate where to send the files. And while we're at it, probably an option to copy vs. move them.

Share this post


Link to post

Hi,

 

I am running two different copies of Dropbox (one personal, one for work). Is there a way for this to support both of them? I use this functionality a whole lot and this workflow will make it much easier. Thanks!

 

How do you have 2 Dropbox copies installed? Or rather, how does Dropbox itself differentiate between the two? I currently use the value stored in ~/.dropbox/host.db to know where the "Dropbox" folder is located on the hard drive. When there are 2 copies of Dropbox installed, where does the 2nd copy store information about itself? A folder other than ~/.dropbox/?

Share this post


Link to post

Hi,

 

I created a directory "Dropbox-envato" and start a new instance of DropBox using the environment set to the new directory. I created a simple workflow to launch that special instance. Once it is running, I change the preferences for that Dropbox to black so that I can tell which one is for which. Therefore, the workflow would need to access those different dropbox directories.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now