Skip to content

Commit

Permalink
fix file name in upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AliHusainLumofy committed Feb 11, 2024
1 parent ba1f65f commit d392776
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions s3direct/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import botocore
import json
from urllib.parse import unquote
from email.message import EmailMessage

from django import forms

Expand Down Expand Up @@ -86,12 +87,10 @@ def validate_url(value, dest):

content_disposition = head_object["ContentDisposition"]
header_value, header_params = cgi.parse_header(content_disposition)
filename = ""
for param_name in ["filename*", "filename"]:
if param_name in header_params:
filename = header_params[param_name].strip("UTF-8''")
filename = unquote(filename)
break

msg = EmailMessage()
msg["Content-Disposition"] = content_disposition
filename = msg.get_filename()

mimetype = head_object["ContentType"]
return {
Expand Down

0 comments on commit d392776

Please sign in to comment.