Reputation: 1
I want to return and get a .xlsx file from a server, and I use the send_file
method in the flask library:
try:
print(filepath)
return send_file(filepath, as_attachment=True, attachment_filename='Controle_Fiches_Appui.xlsx')
except Exception as e:
return str(e)
the filepath is good but when i try to download it from postman or a python client the return file is blank with 0 octect .. please help me
Upvotes: 0
Views: 806
Reputation: 21
You should use send_from_directory rather.
send_file is just creating an empty file and giving it to you, also if its a GET request it will be cached and you will get the same file repetitively.
Why not try downloading in incognito mode to test
Upvotes: 2