Ubuntu One has the concept of publishing a file — that is, giving a file in your personal cloud a URL so that anyone can download it, if you tell them the URL — but you can't currently do that with a whole folder of files. Since that'd be quite a useful thing to be able to do, and it's not yet supported by U1 itself, I wrote a little script to do it, u1-publish-folder (the script needs you to be on Ubuntu 12.04, which is released next week). Simply do u1-publish-folder /path/to/synced/folder
and it'll give you a URL for the index for that folder; a handy way to get a bunch of files to someone without a U1 account* where they can pick and choose the ones they want (rather than sending them a zip file, or sharing a folder with them).
The way it actually works is to publish all the files in the folder, then create an HTML index file linking to all those published files, then sync and publish the index. So you get a directory listing, like Apache gives you when you browse a folder: List of files in testpublishfolder.
The thing I found nicest about this is working with SyncDaemonTool
, the Python U1 controller. Combined with Twisted's defer.inlineCallbacks
stuff, it makes dealing with U1 really easy:
@defer.inlineCallbacks
def dosomething():
sd = SyncDaemonTool()
metadata = yield sd.get_metadata("/home/aquarius/Documents/somefile")
print metadata
Normally, dealing with async stuff is hard, but it's just dead easy this way; simply throw in a yield
and you can write code as if it's normally synchronous but it's actually async, so your program doesn't block while it's working and you don't need to invent a zillion "callback" functions (whether they're anonymous functions or not). I like this.