fix: attachment filename error in sqllab with i18n (#11762)

* Fix attachment filename error in sqllab

* Fix line too long lint

* Fix black lint
This commit is contained in:
auxten 2020-11-25 19:05:30 +08:00 committed by GitHub
parent 38f67a44ca
commit ac0dd3fa32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -2474,9 +2474,11 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
# TODO(bkyryliuk): add compression=gzip for big files.
csv = df.to_csv(index=False, **config["CSV_EXPORT"])
response = Response(csv, mimetype="text/csv")
response.headers[
"Content-Disposition"
] = f"attachment; filename={query.name}.csv"
quoted_csv_name = parse.quote(query.name)
response.headers["Content-Disposition"] = (
f'attachment; filename="{quoted_csv_name}.csv"; '
f"filename*=UTF-8''{quoted_csv_name}.csv"
)
event_info = {
"event_type": "data_export",
"client_id": client_id,