Media object max size when sent to server

Hi Everyone

I recently discovered that it seems like Media objects above a certain size cannot be sent as an argument to a server method without the “anvil.server.TimeoutError: Server code took too long” error being raised.

To test where exactly this limit is i wrote the following code (#MB# represents amount of mb):

CLIENT:

test_file = anvil.BlobMedia(“text/plain”, f"{‘x’ * int(#MB# * 1000000)}".encode())
print(f"{test_file.length * 0.000001} mb")
anvil.server.call(‘capacity_test’, test_file)

SERVER:

@anvil.server.callable
def capacity_test(file):
print(“sucess!”)

It seems like the size limit is somewhere between 27.898 and 27.899 mb. Of course this might vary based on internet connection or Anvil Plan. Feel welcome to use this code to test the limit for yourself.

There’s a technique to get around the upload timeout that involves client writeable views: File upload timeout - #2 by jshaffstall

1 Like

Thanks for sharing this, very usefull