0

My current flow is that the user posts a form, I fetch a DataFrame using their input, and I try to start a download for a csv containing the DataFrame's data.

Current code:

return Response(
    df.to_csv(),
    mimetype="text/csv",
    headers={"Content-disposition": "attachment; filename=output.csv",
                         'Content-Type': 'application/octet-stream'})

This correctly starts a download for smaller amounts of data, but if I across some unknown size threshold, no download starts. I am printing the head of the DataFrame each time, so I know that operation is working.

My guess is that it is somehow timing out, or not accepting the Response because of the file size.

I added the octet stream header from another similar thread.

Edit: it may have been Chrome's automatic download blocking. Not sure how to get around that, i.e. make a regular download that Chrome doesn't find suspicious.

kevinlinxc
  • 470
  • 5
  • 20

1 Answers1

-1

I'm running a Flask app and have been suffering from similar symptoms since the beginning of this year. I generated xlsx and let download the file with send_file(). This was all working until last year. I have multiple pages within the app that have the same functionality and some continue to work correctly. I thought that send_file() might be the cause, so I started using response(), but the download stopped halfway through. Checked with Chrome, safari, firefox.

However, this does not reproduce locally, it occurs when operating on EC2.

YMohrey
  • 1
  • 1
  • This was a while ago, but I'm pretty sure the issue was resolved after I allowed the website to automatically download files/automatically download multiple files in browser settings. It seems dumb, but check for little icons in your browser in case this is the issue. – kevinlinxc Jan 26 '23 at 20:06
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/33710846) – Radinator Jan 31 '23 at 12:26