I have a my_folder.tar.gz
archive with a structure
my_folder.tar.gz:
my_folder/
file1
file2
And I construct a basic flask endpoint, say:
@blueprint.route('/download')
def download():
return send_file('/path/to/my_folder.tar.gz',
as_attachment=True,
attachment_filename='my_name.tar.gz')
And when I run it the first time everything runs smoothly and the browser downloads the proper archive. The thing is when I run it the second time, inside the archive there's a file my-name.tar-1
and not the folder I was hoping to send. I try another time, the filename my-name.tar-2
etc etc.
It turns out that when I change the attachment_filename
parameter to a new value, the download works again but also only once. The same situation happens with the send_from_directory()
function.
That's a very bizarre behaviour. Does anybody have an idea what might be happening?