The Artima Developer Community
Sponsored Link •

Web Buzz Forum
Downloading all the files in an Ubuntu One folder

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Stuart Langridge

Posts: 2006
Nickname: aquarius
Registered: Sep, 2003

Stuart Langridge is a web, JavaScript, and Python hacker, and sometimes all three at once.
Downloading all the files in an Ubuntu One folder Posted: Feb 29, 2012 4:14 PM
Reply to this message Reply

This post originated from an RSS feed registered with Web Buzz by Stuart Langridge.
Original Post: Downloading all the files in an Ubuntu One folder
Feed Title: as days pass by
Feed URL: http://feeds.feedburner.com/kryogenix
Feed Description: scratched tallies on the prison wall
Latest Web Buzz Posts
Latest Web Buzz Posts by Stuart Langridge
Latest Posts From as days pass by

Advertisement

Ubuntu One syncs your files and folders. However, sometimes you don't, or can't, sync your files; you're using the web UI on someone else's computer, you're on a machine we don't support, that sort of thing. You can always use the web interface, of course, but as yet the web UI doesn't support downloading a whole folder in one go, and that can be a pain if you want to download many files at once. To alleviate that for myself, I have a quick bookmarklet. As usual, just right-click the link and "Add to bookmarks" (or however you normally do that), and then when you're looking at a folder in the Ubuntu One web UI, you can click the bookmark and it'll download all the files in that folder.

First, the caveats: it only works in Chrome (and only recent Chrome, at that; sorry; if you care why, see the explanation below), and it will download all the files in this folder to your Downloads folder (that is: it will not create a new folder and download them into that).

Second, the bookmarklet itself:

Download U1 folder

Third, a brief explanation, for those of you who are technical people who want it and can't decipher the code:

  • First, we look for a[download] support (currently only in Chrome), which allows an ordinary HTML link to specify that when clicked its destination should be downloaded (with a specific name) rather than opened.
  • Then we grab all the links to files on the page you're looking at; we assume this is an Ubuntu One page, so we look for links with querySelectorAll('.files-td-name a').
  • That's a NodeList, not an array, which means we can't use forEach on it; we convert it to an array with Array.prototype.slice.call(nodelist), which is a trick I use a lot (can't remember who I first learned this from, but it's neat)
  • and for each of the links, construct a new link, set the new link's href to the existing link's href and its download attribute to the filename, and then fake a mouse click on the new link with event.initMouseEvent. (We construct a new link because the existing links in the page have onclick handlers, which we don't want to fire.)
  • ta daah, the link downloads without further prompting, to your Downloads folder (because that's where Chrome puts it).

Read: Downloading all the files in an Ubuntu One folder

Topic: Downloading all the files in an Ubuntu One folder Previous Topic   Next Topic Topic: PDF to Excel Converter Serial Key for Full Version Activation

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use