Django media on Heroku, Boto or Cloudinary

amazon-s3, boto, cloudinary, django, heroku

Solution

You're not necessarily missing a better solution. The problem with Heroku is that if you want to upload anything larger than a few mb - or more crucially you want to do this over a potentially slow connection - you're going to hit hard timeouts, because Django works by first accepting your file as it was posted in the form, then uploading it - via the Heroku dyno - to a cloud storage provider.

I would normally suggest setting your client up with an AWS account so they get S3 and CloudFront, and then using s3direct. This does unfortunately involve changing `ImageField`s and other potentially large `FileField`s to `S3DirectField`s, which store the entire URL to a file (either on S3 or CloudFront). This then provides your model admin with an AJAX-enabled uploader for each field. It works great, as long as you hit "Submit" after all the images are uploaded.

I use it on my podcast network site as, by its nature we have to deal with files that'll take a little time to upload. You can - and indeed have to - tweak S3Direct so that it only accepts the file types you want, per field - which you do in your settings.py file - but it works pretty well, and gives the user a progress bar.

Who well this integrates with Django CMS, I couldn't tell you, but I've used it with the Suit skin for the admin, and had no problems.

Hope that helps.

Problem

I'm developing for a client a Django CMS project that uses Aldryn Blog via an apphook. I'm attempting to deploy to Heroku. Because of Heroku's ephemeral file system, media will have to be hosted externally. Currently the only media consists of Django CMS Picture plugins (which use a standard ImageField) and Aldryn Blog posts (which use a FilerImageField and easy_thumbnails). I've read about using Boto to store to S3, which seems to be as simple as setting a new DEFAULT_FILE_STORAGE (and THUMBNAIL_DEFAULT_STORAGE). This seems like a great solution, but everything else (web server, search engine, database) is provided by Heroku and its addons. When the client signs off, I'd like to simply transfer Heroku ownership. This led me to consider using Cloudinary as a Heroku addon, but I'm confused about integration. Instead of simply changing DEFAULT_FILE_STORAGE, would I have to change ImageFields and FileImageFields to CloudinaryFields and lose (or be forced to somehow monkey patch in) Filer and easy_thumbnail functionality? It seems like I either choose Boto and client credit card goes to both Heroku and S3, or I choose Cloudinary and deal with a rough integration. Am I missing a better solution?

Original source