What I’m trying to do:
I want to transfer a set of different files selected by the user using Fileloader to an SQLite database located on my laptop. These file would be: an image file, a docx file, rich text file, plain text file. The files would be stored in the SQLite database as BLOBs.
Once saved in the database, I want to be able to then retrieve them in an Anvil App and save them to a separate files on my laptop. In the case of the image file and the rich text files, I also want to be able to display the image in an Anvil Image and also display the rich text data in a rich text box.

Its a hobby project. I’m just looking for pointers to a solution and in particular how in general I can exchange media files between an Anvil App on my laptop and python code on my server using the Uplink. I have no problem with using the uplink in general. I just can’t see an obvious path when using media files.

Any thoughts welcome.
Here’s my updated version of this to work with the modern (as of January 2022) anvil.yaml file format. I only use this with a Git version of the file, not with an exported one. from __future__ import annotations # standard-lib modules: import pathlib import sqlite3 as dblib import datetime import json import shutil # third-party modules: import yaml # i.e., py -m pip install pyyaml # web-service imports import anvil.server from tables import app_tables # Note: Reading a full-project .yam…

  • Upload the file using fileloader, and save to an Anvil data table
  • Retrieve the file as ‘media_object’, from the data table
  • You can get the bytes as media_object.get_bytes()
  • import anvil.media
    with anvil.media.TempFile(media_object) as file_name:
    # Now there is a file in the filesystem containing the contents of media_object.
    # The file_name variable is a string of its full path.

    This article explains how to insert and retrieve binary files and images in sqlite:

    Python SQLite BLOB to Insert and Retrieve file and images

    Insert and read BLOB data from SQLite using Python. Insert file, image, video, or a song as a blob data into SQLite table and Fetch the file, image, video, song stored as BLOB from SQLite table using Python.

    Est. reading time: 6 minutes

    Thanks very much for the feedback.
    I will have a look at this route.
    I have no idea about how Anvil+YAML works.
    Thanks for the feedback.
    I think I have the transfer from Server+SQLite working for .jpg, .docx, .txt working.
    On the server side on my laptop connected to the SQLite db I retrieve the data from the database using the PYnative link you provide. Then I write it to a file as per the PYnative link.
    Then I use the line media_object_photo = anvil.media.from_file(photoPath, “text/plain”) where photoPath is the location of the file on my laptop drive.
    I then add media_object_photo to a dictionary of items I return to the Anvil app.
    Its a bit clunky as I read the database item as a BLOB, store it to a file, read it back from the same file to convert it to an anvil.media, then transfer it back to the Anvil App world as a dictionary item when called by the Anvil App.

    I haven’t as yet figured a solution for going the other direction from the Anvil app to my server code on my laptop. I will attempt the Anvil data table route as you suggest.

    Thanks