Utils in SDK

Use utility functionalities of the SDK.


Overview

Utils provide access to utility functionalities of the SDK.

View repository

Class: ImageFile

A class that enables access to files, including authenticated ones.

Attributes

AttributeDescription
urlstr
The URL of the file to be downloaded.
file_namestr
The name of the file to be saved locally. If not provided by the server or specified by the user, defaults to output.
Python
import pathlib
# Select a URL
url = "https://storage.googleapis.com/user-storage-interstellar-prod/assets/a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Define a directory to store the downloaded image
output_directory = pathlib.Path("downloaded_images")
output_directory.mkdir(exist_ok=True)
# Instantiate the file
image_file = up42.utils.ImageFile(
url=url,
file_name="my_mage_name" # This will be used as the filename
)
# Download to the desired output directory
downloaded_file_path = image_file.download(output_directory=output_directory)
print(f"\nDownload finished.")
print(f"File was saved to: {downloaded_file_path}")

Methods

download

Downloads the file into the specified folder. Returns pathlib.Path.

ParameterDescription
output_directoryUnion[str, pathlib.Path]
The file output directory.
Python
import pathlib
# Select a URL
url = "https://storage.googleapis.com/user-storage-interstellar-prod/assets/a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Define a directory to store the downloaded image
output_directory = pathlib.Path("downloaded_images")
output_directory.mkdir(exist_ok=True)
# Instantiate the file
image_file = up42.utils.ImageFile(
url=url,
file_name="my_mage_name" # This will be used as the filename
)
# Download to the desired output directory
downloaded_file_path = image_file.download(output_directory=output_directory)
print(f"\nDownload finished.")
print(f"File was saved to: {downloaded_file_path}")

Last updated: