TiH0 commited on
Commit
ca49f0f
·
verified ·
1 Parent(s): 9694a99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -71,10 +71,12 @@ async def convert_file(
71
  detail="Invalid color format. Use 6-character hex code (e.g., '5FFFDF')"
72
  )
73
 
74
- with tempfile.NamedTemporaryFile(delete=False, suffix='.xlsx') as temp_input:
75
- content = await file.read()
76
- temp_input.write(content)
77
- temp_input_path = temp_input.name
 
 
78
 
79
  output_filename = file.filename.replace('.xlsx', '_converted.docx')
80
  temp_output_path = tempfile.mktemp(suffix='.docx')
 
71
  detail="Invalid color format. Use 6-character hex code (e.g., '5FFFDF')"
72
  )
73
 
74
+ original_name = Path(file.filename).stem
75
+ temp_dir = tempfile.mkdtemp()
76
+ temp_input_path = os.path.join(temp_dir, f"{original_name}.xlsx")
77
+
78
+ with open(temp_input_path, "wb") as f:
79
+ f.write(await file.read())
80
 
81
  output_filename = file.filename.replace('.xlsx', '_converted.docx')
82
  temp_output_path = tempfile.mktemp(suffix='.docx')