scystream.sdk.file_handling package#
Submodules#
scystream.sdk.file_handling.s3_manager module#
- class scystream.sdk.file_handling.s3_manager.S3Config[source]#
Bases:
BaseModel
Configuration for accessing an S3-compatible service.
This model holds the necessary parameters to authenticate and connect to an S3-compatible service.
- Parameters:
S3_ACCESS_KEY – access key for authentication.
S3_SECRET_KEY – secret key for authentication.
S3_HOST – The endpoint URL for the S3-compatible service.
S3_PORT – The port used by the S3-compatible service.
- S3_ACCESS_KEY: str#
- S3_HOST: str#
- S3_PORT: str#
- S3_SECRET_KEY: str#
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class scystream.sdk.file_handling.s3_manager.S3Operations[source]#
Bases:
object
A class that encapsulates operations on an S3-compatible service.
This class includes methods to upload and download files to/from an S3 bucket. It also ensures the bucket exists before performing any operations.
- __init__(config: S3Config | FileSettings)[source]#
Initializes the S3 client with the provided configuration.
- Parameters:
config – An instance of the S3Config model containing the
necessary authentication and connection information.
- download_file(bucket_name: str, s3_object_name: str, local_file_path: str)[source]#
Downloads a file from an S3 bucket to a local path.
This method downloads the specified file from the given S3 bucket and saves it to the local filesystem.
- Parameters:
bucket_name – The name of the S3 bucket from which to download the file.
s3_object_name – The name of the file in the S3 bucket that will be downloaded.
local_file_path – The local path where the downloaded file will be saved.
- Raises:
ClientError – If there is an error with the S3 client, such as a failed download.
- upload_file(path_to_file: str, bucket_name: str, target_name: str)[source]#
Uploads a file from the local filesystem to an S3 bucket.
This method uploads a file to the specified S3 bucket, creating the bucket if it does not exist.
- Parameters:
path_to_file – The path to the local file that needs to be uploaded.
bucket_name – The name of the S3 bucket where the file will be uploaded.
target_name – The name the file will have once it is uploaded to the bucket.
- Raises:
ClientError – If there is an error with the S3 client, such as a failed upload.