Flickr as Django Storage

Flickr as Django Storage

Published April 1, 2016 in Cloud, Development, Web - Last update on April 8, 2016.

As explained in previous article, I decided to store my photos on Flickr. It isn't written on the paper but's it's a quite cheap cloud solution. And like all object storage, it has a public HTTP API for automate actions. Open source communities purpose a lot of client implementation in many languages, and there are several in Python too.

Specifically in Django they are two, for synchronize in database or show a gallery. But my goal is to use Flickr as a traditionnal file storage and let developers integrate it easily in Django mechanisms.

Meaning what ?

Django has its own Storage API used for handle static and media files. By default, the filesystem is used, but all the most used cloud providers are already implemented in Django-Storage-Redux. I've already made storage drivers by contributing on django-dbbackup for use the agnostic Django API. This API is quite simple so I decided to use it and add image related features.

So what you've done ?

I made Flickr Pony, a ±Django app for play simply in read/write with Flickr. As Flickr isn't a classic file storage, I adapt several things:

  • Each directory is a user one, and all directory have a flat hierarchy. You list files with user ID instead of a path.
  • Photos are accessible by their ID instead of name. You are allowed to access to any public photo.
  • By default, original file URL will be returned, I make usage of Flickr's thumbnail system for get smaller sizes.
  • Write, Delete and get URL operations are implemented (read is coming)
  • Helper to configure it from settings

If I got more free time or if you want to contribute, it will:

  • Integrate with models.ImageField, maybe you can but untested
  • Have a smart cache behavior
  • CLI management
  • Django Admin integration

I already ensure with Travis CI, Python 2.7-3.5, Django 1.6-1.9, so contributions are very welcome.

If you want a demo, there's one here (not sure it's online, it's a free heroku).

And ?

Nothing, now I can simply follow my README and install it on my blog.

update: The demo can be simply my photo section.

Comments

No comments yet.

Post your comment

Comment as . Log out.