ActiveStorage Help Needed

I create a CSV in a tempfile. When I am done with that, I write it out

 mymodel.my_file.attach(io:, filename: "report.csv")

I generate a link to that file using:

 link = Rails.application.routes.url_helpers.rails_storage_proxy_url(my_model.my_file)

But that link is failing as soon as the file get bigger than a few hundred rows of CSV. I have no idea why this is failing on parts…

Users/beer/Downloads/fWQuGGYF.csv.part could not be saved, because the source file could not be read.

Very frustrating. What am I doing wrong where I am getting links to half-baked stuff. Is there something I have to do in the attach method before generating the link?