Skip to main content

download_url.py

Source: sunholo/gcs/download_url.py

Functions

construct_download_link(source_uri: str) -> tuple[str, str, bool]

Creates a viewable Cloud Storage web browser link from a gs:// URI.

get_bytes_from_gcs(gs_uri)

Downloads a file from Google Cloud Storage and returns its bytes.

Args: gs_uri (str): The Google Cloud Storage URI of the file to download (e.g., 'gs://bucket_name/file_name').

Returns: bytes: The content of the file in bytes, or None if an error occurs.

get_image_from_gcs(gs_uri: str)

Converts image bytes from GCS to a PIL Image object.

Creates a viewable Cloud Storage web browser link from a gs:// URI.

Args: source_uri: The gs:// URI of the object in Cloud Storage.

Returns: A URL that directly access the object in the Cloud Storage web browser.

get_bucket(bucket_name)

No docstring available.

parse_gs_uri(gs_uri: str) -> tuple[str, str]

Parses a gs:// URI into the bucket name and object name.

Args: gs_uri: The gs:// URI to parse.

Returns: A tuple containing the bucket name and object name.

refresh_credentials()

No docstring available.

sign_gcs_url(bucket_name: str, object_name: str, expiry_secs=86400)

No docstring available.

Sunholo Multivac

Get in touch to see if we can help with your GenAI project.

Contact us

Other Links

Sunholo Multivac - GenAIOps

Copyright ©

Holosun ApS 2024