diff --git a/binder/views.py b/binder/views.py index 18c28a23..ecdeeae5 100644 --- a/binder/views.py +++ b/binder/views.py @@ -2699,6 +2699,7 @@ def dispatch_file_field(self, request, pk=None, file_field=None): try: if serve_directly: resp = HttpResponse(content_type=content_type) + resp['X-Accel-Redirect'] = '/internal/media/' + file_field.name else: resp = StreamingHttpResponse(file_field.open(), content_type=content_type) except FileNotFoundError: @@ -2706,8 +2707,6 @@ def dispatch_file_field(self, request, pk=None, file_field=None): raise BinderNotFound(file_field_name) if 'download' in request.GET: - if serve_directly: - resp['X-Accel-Redirect'] = '/internal/media/' + file_field.name filename = self.filefield_get_name(instance=obj, request=request, file_field=file_field) if 'prefix' in request.GET: filename = request.GET['prefix'] + ' - ' + filename