Downloading Files
To download files locally:Caching File Downloads
By default, thedownload
method will not cache the file. To enable caching, pass cache=True
.
If you do not provide a local destination path, the file will be downloaded to the default
~/.latch/
directory. Without caching enabled, this can result in multiple downloads of the same file, unnecessarily increasing storage usage. To avoid this, it is strongly recommended to set a destination path and enable caching, especially when using LPath in Latch Pods or Latch Plots.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
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.