ccnmtl/dmt — pull request #48 by thraxil (2014-07-03 19:42:00+00:00)
Title: add attachment to item

First pass on direct to S3 uploads. Sticking fairly close to the approach
outlined here:

https://devcenter.heroku.com/articles/s3-upload-python

This is still a bit wonky for a few reasons.

1) I'm trying to get through what I can without actually changing the existing
attachment database schema and keeping things slightly backwards
compatible with the PMT. Once we can turn off the PMT, we can
clean quite a bit of this up.

2) I haven't really figured out the best way to handle arbitrary
mimetypes yet. The s3upload js library sends the mimetype to
the /sign_s3/ endpoint and that gets passed on to S3, but it doesn't
seem to give /sign_s3/ the actual filename/extension of the file
that the user started with. So it is limited to guessing based on the
mimetype. For now, it just handles a couple image types and punts on anything
else. We'll definitely want to work that out so spreadsheets, etc can
be uploaded.

OK. To actually try this out for yourself on a dev instance, you will
need to set a few things up. First, you'll need the AWS keys. Get them
from our password wallet and put them in a local_settings.py. You'll
also need to specify a AWS_S3_UPLOAD_BUCKET that your AWS account can write to.
For us, "ccnmtl-dmt-uploads-dev" works for development.

You'll also need to add an 's3_upload' waffle flag through Django admin and enable
it.