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)
@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.
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!
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.
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.