heaptree-logo
Heaptree

Upload

Upload a local file to a node and transfer it to its filesystem

Signature

def upload(node_id: str, file_path: str, destination_path: str = "/home/ubuntu/Desktop/MY_FILES/") -> UploadResponse

Parameters

  • node_id (str) – target node
  • file_path (str) – local path to the file
  • destination_path (str, optional) – directory path on the node where the file will be placed (defaults to /home/ubuntu/Desktop/MY_FILES/)

Path Handling

Important: destination_path is a directory path, not a file path. Your original filename from file_path is preserved and placed in the destination directory.

Default: /home/ubuntu/Desktop/MY_FILES/

Any provided destination_path is constrained to /home/ubuntu/. Paths are automatically adjusted:

  • Absolute path starting with /home/ubuntu/: Used as-is
    • Example: /home/ubuntu/data//home/ubuntu/data/
  • Absolute path starting with /: Forced under /home/ubuntu/
    • Example: /data//home/ubuntu/data/
  • Relative path: Appended to /home/ubuntu/
    • Example: data//home/ubuntu/data/

Returns

UploadResponse object with:

  • status (str) – operation status
  • file_path (str) – local file path that was uploaded
  • destination_path (str) – path on the node where file was placed
  • node_id (str) – target node ID

Examples

Upload to the default directory:

result = client.upload(
    node_id, 
    file_path="./data.csv"
)
print(f"File uploaded to: {result.destination_path}")
# Output: /home/ubuntu/Desktop/MY_FILES/data.csv

Upload to a custom directory:

result = client.upload(
    node_id, 
    file_path="./script.py",
    destination_path="/projects/scripts"
)
print(f"File uploaded to: {result.destination_path}")
# Output: /home/ubuntu/projects/scripts/script.py

Exceptions

  • FileNotFoundError
  • MissingCredentialsException
  • InstanceNotReadyException
  • InvalidRequestParametersException
  • InvalidDestinationPathException
  • TransferFailedException
  • InternalServerErrorException