Table.add_files(*, files=None, directory=None) → list(File)

Uploads either a list of files or all files in a directory to an index table. The index table must be on an unreleased version. Attempting to add files to a non-index table will result in an error.


files : list(str) | list(dict<path=str, name=str, data=str | bytes>), default None A list of files to upload. Either this or directory must be specified, but not both. Can either be a list of file paths, or a list of dicts with the keys path, name, and/or data. If providing a list of dicts, each dict must specify either path (the path to the file on disk) or data, representing the content to upload. name is optional if path is specified (defaulting to the file name), but required if data is specified.

directory : str, default None A directory of files to upload. Either this or files must be specified, but not both. All files in the directory will be uploaded, including hidden files and those in any subdirectories.




dataset = redivis.user("my_username").dataset("my_dataset")

table = dataset.table("my_files")
# If the file index table doesn't already exist, we can create it
# table.create(is_file_index=True)

# upload all contents in a directory

# upload specific files
    {"path": "/path/to/file.png"}, # file name will be "file.png"
    {"path": "/path/to/other/file.png", "name": "other_file.png"}, # file name will be other_file.png
    {"data": "Hello world", "name": "hello_world.txt"} # Data can be string or bytes 

Last updated