Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add suffix to temporary file

IKarbowiake0a4833bd360
diff --git a/saleor/csv/utils/export.py b/saleor/csv/utils/export.py
index 48d68ff874..9672fb7164 100644
--- a/saleor/csv/utils/export.py
+++ b/saleor/csv/utils/export.py
@@ -123,15 +123,14 @@ def export_products_in_batches(
append_to_file(export_data, headers, temporary_file, file_type, delimiter)
-def create_file_with_headers(
- file_headers: List[str], delimiter: str, file_type: str,
-):
+def create_file_with_headers(file_headers: List[str], delimiter: str, file_type: str):
table = etl.wrap([file_headers])
- temp_file = NamedTemporaryFile("ab+")
if file_type == FileTypes.CSV:
+ temp_file = NamedTemporaryFile("ab+", suffix=".csv")
etl.tocsv(table, temp_file.name, delimiter=delimiter)
else:
+ temp_file = NamedTemporaryFile("ab+", suffix=".xlsx")
etl.io.xlsx.toxlsx(table, temp_file.name)
return temp_file