Note that I set the permissions on that table so that client code can read it. Data Tables can hold much more data than theme assets, so this is the solution I would recommend.
What if you only want to read it from a server module and NOT client code. In particular: reading a csv file from a background task in order to populate a database table?
I’m storing some files in a Data Table with a Media column as suggested. My problem is I have a bunch of files and they change once in a while (through local editing).
Is there a way to “bulk upload” them to the Data Table with python code via Uplink?
Thanks. What I meant was how do I “send over” the files to the database. The answer is with BlobMedia objects like so (for future reference):
for file_name in os.listdir(path):
with open(path + file_name, 'rb') as file:
file_contents = file.read()
media = anvil.BlobMedia(content_type="text/plain", content=file_contents, name=file_name)
table.add_row(name=file_name.split('.')[0], file=media)
(I was confused at first because I thought Media objects can only be certain “Media” files like images, videos, etc. which is of course not the case, can be any binary string file content)