richleland/django-cumulus — pull request #46 by tgecho (2012-03-07 18:10:44+00:00)
Title: Add support for custom headers

I've added support for uploading files with custom headers based on a regex pattern.The primary use I have for this ATM is to set the Access-Control-Allow-Origin header on webfont files so that Firefox can use them.

Usage is to put a tuple of regex/header pairs in settings. The first to match is applied to the file on upload, either via syncstatic or using the storage.

CUMULUS = {
'HEADERS': (
(r'.*\.(eot|otf|woff|ttf)$', {
'Access-Control-Allow-Origin': '*'
}),
)
}

The only catch is that this depends on functionality just added to python-cloudfiles about 3 months ago (https://github.com/rackspace/python-cloudfiles/commit/f6682600bc8a4c55b6818d9c53e2ac34da153b28), so it requires the github version until they roll a release. Until then I've set it up to silently skip if the storage_obj doesn't have a headers attribute.

Let me know what you think. I can whip up some tests and docs if you like it.