Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Support for custom content-types #27

wants to merge 2 commits into from

2 participants


At the moment it is relying entirely on mimetype to guess the content type, and fallback to 'application/octet-stream', and there is the possibility of some types not available yet on the python library, such as:

This pull request enables the following optional setting.

MEDIASYNC['MIMETYPES'] =  {'video/webm':'.webm', 'video/webm':'.WebM',}




Hey Alfredo,

I think the built-in mimetypes library can take of this without having to add mediasync support. In your settings file (or elsewhere), you can add:

import mimetypes
mimetypes.add_type('video/webm', '.webm')

That will take effect globally so it will be picked up during syncing without having to make mediasync aware. If that doesn't work for you, we can figure out the best way to have mediasync support this.



Interesting, I assumed that because mimetypes were imported in mediasync, it would need to be done there, but if that works from the settings I think that will do it. I'll have a play and comment back.



Hey Jeremy,

As you suggested adding mimetype and the setting does the trick, thanks for your help, I will close my pull request.


This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 16, 2011
  1. Support for custom content-types

    Alfredo authored
Commits on Feb 17, 2011
  1. FORCE_NON_GZIP setting added

    Alfredo authored
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 3 deletions.
  1. +3 −2 mediasync/
  2. +1 −1  mediasync/templatetags/
5 mediasync/
@@ -124,7 +124,6 @@ def sync(client=None, force=False, verbose=True):
# combine_files() is only interested in CSS/JS files.
filedata, dirname = filedata
content_type = mimetypes.guess_type(joinfile)[0] or 'application/octet-stream'
remote_path = joinfile
@@ -150,7 +149,9 @@ def sync(client=None, force=False, verbose=True):
# calculate local and remote paths
filepath = os.path.join(dirpath, filename)
remote_path = "%s/%s" % (dirname, filename)
+ if msettings.get('MIMETYPES'):
+ for mime_type, extension in msettings.get('MIMETYPES').items():
+ mimetypes.add_type(mime_type, extension)
content_type = mimetypes.guess_type(filepath)[0] or 'application/octet-stream'
if not is_syncable_file(os.path.basename(filename)) or not os.path.isfile(filepath):
2  mediasync/templatetags/
@@ -36,7 +36,7 @@ def supports_gzip(self, context):
to the gzipped version of files that are allowed to be compressed.
Clients without gzip support will be served the original media.
- if 'request' in context and client.supports_gzip():
+ if 'request' in context and client.supports_gzip() and not msettings.get('FORCE_NON_GZIP'):
enc = context['request'].META.get('HTTP_ACCEPT_ENCODING', '')
return 'gzip' in enc and msettings['SERVE_REMOTE']
return False
Something went wrong with that request. Please try again.