Files¶
Download¶
Download (simple method)
Download a file to a local path.
Example
Download (detailed method)
This detailed method is for handling complex situations where the file is extremly large or the internet connection is slow. In this example I assume that there exist a file like https://cloud.seatable.io/dtable-web/workspace/74/asset-preview/41cd05da-b29a-4428-bc31-bd66f4600817/files/2020-10/invoice.pdf
.
Example
Download file to local
Example
Upload¶
Upload (simple method)
Upload a file from your local drive, memory or a website.
base.upload_local_file(file_path, name=None, file_type='file', replace=False)
# or
base.upload_bytes_file(name, content, file_type='file', replace=False)
Example: Upload a file from local hard drive
local_file = '/Users/Markus/Downloads/seatable-logo.png'
info_dict = base.upload_local_file(local_file, name='seatable-logo.png', file_type='image', replace=True)
Example: Upload a file from memory
local_file = '/Users/Markus/Downloads/seatable-logo.png'
with open (local_file, 'rb') as f:
content = f.read()
info_dict = base.upload_bytes_file = ('seatable-logo.png', content, file_type='image')
Example: Upload a file from a website
Upload (detailed method)
Get a file upload link.
Example
# Get the upload link and file path allocated by server
upload_link_dict = base.get_file_upload_link()
parent_dir = upload_link_dict['parent_path']
upload_link = upload_link_dict['upload_link'] + '?ret-json=1'
# Upload the file
upload_file_name = "file_uploaded.txt"
replace = 1
response = requests.post(upload_link, data={
'parent_dir': parent_dir,
'replace': 1 if replace else 0
}, files={
'file': (upload_file_name, open('/User/Desktop/file.txt', 'rb'))
})
Upload local file to custom folders
Example
List files¶
List files
List files in custom folders.
Example
Get file info¶
Get file info
The data structure returned can be used to updated cells of file column.
Example