Jump to content


Photo

Dropbox Short Links Workflow

oauth dropbox ruby

  • Please log in to reply
51 replies to this topic

#1 canadaduane

canadaduane

    Member

  • Member
  • PipPip
  • 35 posts
  • LocationSalt Lake City, UT

Posted 06 February 2013 - 07:57 PM

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


  • phyllisstein, jarhead, Kennon Bickhart and 5 others like this

#2 Carlos-Sz

Carlos-Sz

    Advanced Member

  • Member
  • PipPipPip
  • 758 posts

Posted 06 February 2013 - 08:24 PM

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



#3 sphardy

sphardy

    Member

  • Member
  • PipPip
  • 81 posts

Posted 06 February 2013 - 10:44 PM

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



#4 canadaduane

canadaduane

    Member

  • Member
  • PipPip
  • 35 posts
  • LocationSalt Lake City, UT

Posted 07 February 2013 - 01:26 AM

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.



#5 canadaduane

canadaduane

    Member

  • Member
  • PipPip
  • 35 posts
  • LocationSalt Lake City, UT

Posted 07 February 2013 - 01:27 AM

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?



#6 canadaduane

canadaduane

    Member

  • Member
  • PipPip
  • 35 posts
  • LocationSalt Lake City, UT

Posted 07 February 2013 - 02:07 AM

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



#7 sphardy

sphardy

    Member

  • Member
  • PipPip
  • 81 posts

Posted 07 February 2013 - 06:59 AM

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



#8 tconte

tconte

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 07 February 2013 - 04:13 PM

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

 

Thanks



#9 canadaduane

canadaduane

    Member

  • Member
  • PipPip
  • 35 posts
  • LocationSalt Lake City, UT

Posted 07 February 2013 - 07:18 PM

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

#10 Allosunshine

Allosunshine

    Member

  • Member
  • PipPip
  • 23 posts
  • LocationHigh Wycombe

Posted 07 February 2013 - 10:07 PM

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



#11 sphardy

sphardy

    Member

  • Member
  • PipPip
  • 81 posts

Posted 07 February 2013 - 10:17 PM

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



#12 canadaduane

canadaduane

    Member

  • Member
  • PipPip
  • 35 posts
  • LocationSalt Lake City, UT

Posted 08 February 2013 - 04:40 PM

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.



#13 canadaduane

canadaduane

    Member

  • Member
  • PipPip
  • 35 posts
  • LocationSalt Lake City, UT

Posted 08 February 2013 - 04:41 PM

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]
 
:(


#14 sphardy

sphardy

    Member

  • Member
  • PipPip
  • 81 posts

Posted 08 February 2013 - 04:43 PM

 
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?



#15 canadaduane

canadaduane

    Member

  • Member
  • PipPip
  • 35 posts
  • LocationSalt Lake City, UT

Posted 08 February 2013 - 11:21 PM

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....erence/branding

 

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

 

 
Duane


#16 canadaduane

canadaduane

    Member

  • Member
  • PipPip
  • 35 posts
  • LocationSalt Lake City, UT

Posted 08 February 2013 - 11:36 PM

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

#17 sphardy

sphardy

    Member

  • Member
  • PipPip
  • 81 posts

Posted 09 February 2013 - 07:27 AM

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



#18 andrewconner

andrewconner

    Newbie

  • Member
  • Pip
  • 1 posts

Posted 10 February 2013 - 10:42 PM

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!



#19 phyllisstein

phyllisstein

    Advanced Member

  • Member
  • PipPipPip
  • 370 posts
  • LocationNew York, NY

Posted 11 February 2013 - 04:45 AM

Great work! This should come in very handy.


alp, Alfred.framework, and my assorted workflows are now abandonware. You can find them at https://github.com/p...stein/Workflows.

 


#20 Carlos-Sz

Carlos-Sz

    Advanced Member

  • Member
  • PipPipPip
  • 758 posts

Posted 11 February 2013 - 11:28 PM

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!

 

I made a workflow that moves a file to Public folder and then copies the URL:

 

     [Workflow] Move selected Finder file to Dropbox + URL to clipboard    





Also tagged with one or more of these keywords: oauth, dropbox, ruby

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users