Working with Remote Files
The Latch SDK provides a convenient means of referencing files or directories hosted on Latch within task functions.
Downloading Files
To download files locally:
To download files to a pre-determined local path:
Uploading Files
To upload files from a local path to a Latch path:
To upload to a remote path, the parent directory of the
remote path must already exist. To ensure that the parent directory
exists, use LPath("latch:///parent_directory").mkdirp()
.
Copying Between Latch Paths
Copy data from one Latch path to another:
Deleting Latch Files
Recursively remove a remote file or directory:
Fetching File Metadata
Use the following methods to fetch metadata of your remote files without downloading the file first:
node_id()
name()
content_type()
size()
LPath objects will cache metadata information for the lifetime of the object
after any LPath
method is invoked. To re-populate the cache, use the
LPath().fetch_metadata()
method. For example:
Working with Directories
LPath also provides the methods for working with remote directories. For example:
The size_recursive
method can be very slow on large directories and should only be used
if absolutely necessary
Was this page helpful?