Skip to content

Transfer

This module is used to upload files using HTTP requests.

push(local_filename, target_url)

Publish a local file to the cloud.

Source code in teledetection/upload/transfer.py
def push(local_filename: str, target_url: str):
    """Publish a local file to the cloud."""
    remote_presigned_url = sign_url_put(target_url)

    session = create_session()

    with open(local_filename, "rb") as f:
        ret = session.put(remote_presigned_url, data=f, timeout=10)

    if ret.status_code == 200:
        return remote_presigned_url

    ret.raise_for_status()
    return ""