def upload_from_directory()

in radlab-launcher/radlab.py [0:0]


def upload_from_directory(projid, directory_path: str, content: str, dest_bucket_name: str, dest_blob_name: str):
    rel_paths = glob.glob(directory_path + content, recursive=True)

    bucket = storage.Client(project=projid).get_bucket(dest_bucket_name)
    for local_file in rel_paths:
        file = local_file.replace(directory_path, '')
        remote_path = f'{dest_blob_name}/{"/".join(file.split(os.sep)[1:])}'

        if os.path.isfile(local_file):
            blob = bucket.blob(remote_path)
            blob.upload_from_filename(local_file)