Utils provide access to utility functionalities of the SDK.
View repositoryA class that enables access to files, including authenticated ones.
Attributes
Attribute | Description |
---|---|
url | str The URL of the file to be downloaded. |
file_name | str The name of the file to be saved locally. If not provided by the server or specified by the user, defaults to output . |
import pathlib
# Select a URLurl = "https://storage.googleapis.com/user-storage-interstellar-prod/assets/a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Define a directory to store the downloaded imageoutput_directory = pathlib.Path("downloaded_images")output_directory.mkdir(exist_ok=True)
# Instantiate the fileimage_file = up42.utils.ImageFile( url=url, file_name="my_mage_name" # This will be used as the filename)
# Download to the desired output directorydownloaded_file_path = image_file.download(output_directory=output_directory)print(f"\nDownload finished.")print(f"File was saved to: {downloaded_file_path}")
Methods
Downloads the file into the specified folder. Returns pathlib.Path
.
Parameter | Description |
---|---|
output_directory | Union[str, pathlib.Path] The file output directory. |
import pathlib
# Select a URLurl = "https://storage.googleapis.com/user-storage-interstellar-prod/assets/a0d443a2-41e8-4995-8b54-a5cc4c448227"
# Define a directory to store the downloaded imageoutput_directory = pathlib.Path("downloaded_images")output_directory.mkdir(exist_ok=True)
# Instantiate the fileimage_file = up42.utils.ImageFile( url=url, file_name="my_mage_name" # This will be used as the filename)
# Download to the desired output directorydownloaded_file_path = image_file.download(output_directory=output_directory)print(f"\nDownload finished.")print(f"File was saved to: {downloaded_file_path}")