anvil.server.InternalError when writing bytes to a file

I’m trying to write bytes to a file (an mp3 file) using the following code:

with open(file_name, "wb") as fp:
      fp.write(file.get_bytes())

but I’m getting the following error:

anvil.server.InternalError: Internal server error: f491ec4c2d91
at /downlink/anvil/_threaded_server.py, line 412
called from /downlink/anvil/server.py, line 47
called from /downlink/anvil/_server.py, line 341
called from /downlink/anvil/_server.py, line 372

The file I am trying to write is getting pulled from an Anvil database … previously this was saved as a temp file and it worked fine. Any help would be much appreciated :slight_smile:

Where are you writing it to? Is this in uplink code (running on your own server/laptop)?

Anvil provides a small amount of private ephemeral disk space in /tmp but anything written there is not guaranteed to survive between server calls.

As far as I know you cannot write to any other disk space on Anvil hosted servers.