Skip to main content

File Management

File Management​

Upload and Download Files (Sync)​

You can upload files to a running instance and download files from it using the sync API.

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()

instance_id = "instance_your_instance_id" # Replace with a valid instance ID
instance = client.instances.get(instance_id=instance_id)

# Upload a local file to the instance
instance.upload(source_path="/local/path/to/file.txt", target_path="/remote/path/on/instance/file.txt")

# Download a file from the instance to your local machine
instance.download(source_path="/remote/path/on/instance/file.txt", target_path="/local/path/to/download.txt")

Multi-File Transfer​

For transferring multiple files, use the directory sync operations.

from morphcloud.api import MorphCloudClient

client = MorphCloudClient()

instance_id = "instance_your_instance_id" # Replace with a valid instance ID
instance = client.instances.get(instance_id=instance_id)

# Upload a directory to the instance (recursive by default)
instance.upload_dir(source_path="/local/directory", target_path="/remote/directory")

# Download a directory from the instance (recursive by default)
instance.download_dir(source_path="/remote/directory", target_path="/local/download_dir")