1 2 3 4 5 6 7 8 | def serve_download(view_func):
def _wrapped_view_func(request, *args, **kwargs):
response = view_func(request, *args, **kwargs)
response['Content-Type'] = 'application/octet-stream';
import os.path
response['Content-Disposition'] = 'attachment; filename="%s"' % os.path.basename(kwargs['path'])
return response
return _wrapped_view_func
|
More like this
- TemplateZipFile by fcurella 1 year, 5 months ago
- A view for downloading attachment by achimnol 3 years, 8 months ago
- DownloadView generic class view by ckniffen 1 year, 8 months ago
- Accept Header Middleware by kioopi 5 years, 1 month ago
- Caching XHTML render_to_response by smoonen 4 years, 10 months ago
Comments