Open Valdanitooooo opened 2 months ago
Hey @Valdanitooooo! I'm here to help you with any bugs or questions you have. Let's figure this out together!
The suffix of the xlsx file might be missing after uploading in the .files
directory because the file.name
attribute is used directly to create the file_path
. If file.name
does not include the suffix, the saved file will also lack the suffix.
Here is the relevant code snippet:
file_path = f"./tmp/{file.name}"
To ensure the suffix is included, you should verify that file.name
contains the correct suffix when the file is uploaded. If it does not, you may need to manually append the suffix based on the file.type
.
For example:
if not file.name.endswith('.xlsx') and file.type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
file_path = f"./tmp/{file.name}.xlsx"
else:
file_path = f"./tmp/{file.name}"
This way, you ensure that the .xlsx
suffix is included in the file path when saving the file [1].
To continue talking to Dosu, mention @dosu.
same but in my development environment (windows server 2012) it can get suffix, weird
Version: 1.2.0 OS: centos7 and windows server 2019
but in my development environment (windows server 2012) it can get suffix, weird
Me too. My macos development environment is fine, but using docker containers in the production environment may cause this issue.
My current solution is to check if the file path has a suffix, and then add the suffix from the file name to the file path.
Describe the bug Missing file suffix when uploading xlsx file.
To Reproduce Steps to reproduce the behavior:
I have uploaded a txt and an xlsx file. This is my .files directory, bcb2b22f-6611-454d-aa3a-d6b03efc993f without xlsx suffix
Expected behavior The suffix of the xlsx file is retained after uploading
Desktop (please complete the following information):
Additional context