Is there a media file size limit?

Is there a size for sending BlobMedia from a backend server to the front end? Our app appears to run into the issue when sending a file size around 30MB. This only happened recently and we did not have this issue before. The app is Anvil hosted (i.e. not using our own EAS).

After a long wait, we got the following error:
AppOfflineError: Connection to server failed (1006)

But the App and server were both online.

Thanks for your help.

Huarong

Did you know that you can Search, using the :mag: icon above?

https://anvil.works/forum/search?q=media%20size%20limit

@p.colbert Thanks for the reply. I do searched the exact term before I post the question. The most relevant discussion I have found are

This post indicates that the workaround is to use Data Table, which is not ideal for us. There seems no explaination why there is a size limit to transfer media object directly and what the size limit is.

Another relevant one is Anvil Server disconnects when large amounts of data are passed back

In the following post about transferring large amount of data between uplink server and client, the proposed solution is to use Media Object but didn’t mention there is a size limit for Media Object too.

The limitation of Media Object is not discussed in any of the documentation too.

I’m glad to understand more about what has been discussed if I missed something in my search. Thank you very much!

1 Like

My apologies. I could swear I saw a limit per Media Object or per upload, in one of those articles, but you’re right.

Clarity around this would be super helpful

From what I can recall, if the item is a python object it does have some limit. That used to be something like 30MB but they have made it larger in the past, so I am unsure if this is still the limit.

Media objects do not have a “limit” but as in-memory objects they cannot exceed the total allocated memory for the anvil server module you are running, which is different depending on your plan or system if you are running the anvil-runtime open source software on your own system.**

So if you are having trouble moving large amounts of data from within a python object, turn that object into a bytes string somehow by using json or pickle or BytesIO and put that data in a media object before sending it between the server or client or uplink.
On the receiving end, you can then turn the bytes string data back into whatever python object you wish.

** sometimes it is possible to write an object to a disk or database as it is being transmitted/returned, so you do not need to be able to hold the entire data object in memory in the system in all circumstances.

1 Like

I think the limit is 30 seconds, regardless of the file size.

The data table trick allows to upload large files even with slow connections, and works just fine.

Hi Huarong,

It looks like there isn’t a fixed size limit for Media Objects, but memory limits can affect larger files. You can try converting the data into a bytes string using JSON or Pickle and then send it as a Media Object.