I'm using Django Rest Framework to build an API and I'm trying to redirect my endpoint to download files from AWS S3. It's working but in Chrome I'm getting the following warning:
Resource interpreted as Document but transferred with MIME type application/force-download
This is my get method from my view:
def get(self, request, pk, format=None):
file_item = self.get_object(pk)
serializer = FileSerializer(file_item)
response = redirect(serializer.data['file_url'])
return response
As you can see, I have passed content type, why does it Chrome still throw a warning? I need to be able to download files in various formats e.g. pdf, jpg etc.
Update: I have specified the mime type correctly and when I print the response object, this is what I get. Is it the "test/html" header that is causing issues? How do I remove it?
<HttpResponseRedirect status_code=302, "text/html; charset=utf-8", url="https://a.com/xxxx/x.pdf&response-content-type=application/pdf&response-content-disposition=attachment%3Bfilename%3D%22xxx.pdf%22">