🔒️(back) set ContentDisposition on media upload
On the media upload endpoint, we want to set the content-disposition header. Its value is based on the uploaded file mime-type and if flagged as unsafe. If the file is not an image or is unsafe then the contentDisposition is set to attachment to force its download. Otherwise, we set it to inline.
This commit is contained in:
committed by
Anthony LC
parent
3ce1826355
commit
a22bf95bce
@@ -418,6 +418,7 @@ class FileUploadSerializer(serializers.Serializer):
|
||||
|
||||
self.context["expected_extension"] = extension
|
||||
self.context["content_type"] = magic_mime_type
|
||||
self.context["file_name"] = file.name
|
||||
|
||||
return file
|
||||
|
||||
@@ -426,6 +427,7 @@ class FileUploadSerializer(serializers.Serializer):
|
||||
attrs["expected_extension"] = self.context["expected_extension"]
|
||||
attrs["is_unsafe"] = self.context["is_unsafe"]
|
||||
attrs["content_type"] = self.context["content_type"]
|
||||
attrs["file_name"] = self.context["file_name"]
|
||||
return attrs
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user