Thank you. Yes, the text has to be binary. When I copied the example from the docs:
file_contents = "Hello, world"
my_media = anvil.BlobMedia(content_type="text/plain", content=file_contents, name="hello.txt")
I got an error. Maybe because the example was based on Python 2.7 when the string was binary and in the example above you would have to write
file_contents = "Hello, world".encode('utf8')
But I wonder also if there is something else going on as well, because if you try:
file_contents = "Hello, world".encode('utf8')
my_media = anvil.BlobMedia(content_type="text/plain", content=file_contents, name="hello.txt")
you get an error, but (strangely?) it works if we use positional arguments:
file_contents = "Hello, world".encode('utf8')
my_media = anvil.BlobMedia("text/plain", file_contents, "hello.txt")
Here is a copy of an app that shows this behaviour.
https://anvil.works/build#clone:VNTHOGNRJFVNVHIO=3M2BRVCDRUCCZTEDWJPJV5Z6
It is not a problem once you know it, but it was a bit strange. Anyway, thank you for having a look at this.