camel.storages.object_storages 包#

子模块#

camel.storages.object_storages.amazon_s3 模块#

class camel.storages.object_storages.amazon_s3.AmazonS3Storage(bucket_name: str, create_if_not_exists: bool = True, access_key_id: str | None = None, secret_access_key: str | None = None, anonymous: bool = False)[来源]#

基础类: BaseObjectStorage

一个用于连接AWS S3对象存储的类,可从S3存储桶中存取对象。该类会首先尝试使用作为参数传入的凭证,如果未提供,则会查找环境变量AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY。如果这些凭证都未提供,它将尝试使用本地凭证(如果通过AWS CLI登录则会自动创建)。

Parameters:
  • bucket_name (str) - S3存储桶的名称。

  • create_if_not_exists (bool, optional) – 如果存储桶不存在,是否创建它。默认为True。

  • access_key_id (Optional[str], optional) – AWS访问密钥ID。 默认为None。

  • secret_access_key (Optional[str], optional) – AWS密钥访问密钥。 默认为None。

  • anonymous (bool, optional) – 是否使用匿名访问。默认为False。

参考文献

https://aws.amazon.com/pm/serv-s3/

https://aws.amazon.com/cli/

static canonicalize_path(file_path: PurePath) Tuple[str, str][来源]#

为Amazon S3规范化文件路径。

Parameters:

file_path (PurePath) – 需要规范化的路径。

Returns:

规范化的文件键和文件名。

Return type:

元组[str, str]

camel.storages.object_storages.azure_blob 模块#

class camel.storages.object_storages.azure_blob.AzureBlobStorage(storage_account_name: str, container_name: str, create_if_not_exists: bool = True, access_key: str | None = None)[来源]#

基础类: BaseObjectStorage

一个用于连接Azure Blob Storage的类。它将连接到存储账户中的一个容器。

Parameters:
  • storage_account_name (str) - 存储账户的名称。

  • container_name (str) - 容器的名称。

  • access_key (Optional[str], optional) – 存储账户的访问密钥。默认为None。

参考文献

https://azure.microsoft.com/en-us/products/storage/blobs

static canonicalize_path(file_path: PurePath) Tuple[str, str][来源]#

规范化Azure Blob Storage的文件路径。

Parameters:

file_path (PurePath) – 需要规范化的路径。

Returns:

规范化的文件键和文件名。

Return type:

元组[str, str]

camel.storages.object_storages.base 模块#

class camel.storages.object_storages.base.BaseObjectStorage[来源]#

基类: ABC

abstract static canonicalize_path(file_path: PurePath) Tuple[str, str][来源]#
download_file(local_file_path: Path, remote_file_path: PurePath) None[来源]#

从对象存储下载文件到本地系统。

Parameters:
  • local_file_path (Path) – 要保存的本地文件路径。

  • remote_file_path (PurePath) – 存储中对象的路径。

get_file(file_path: PurePath) 文件[来源]#

从对象存储中获取一个文件。

Parameters:

file_path (PurePath) – 存储中对象的路径。

Returns:

从存储中获取的文件对象。

Return type:

文件

object_exists(file_path: PurePath) bool[来源]#

检查对象是否存在于存储中。

Parameters:

file_path (PurePath) – 存储中对象的路径。

Returns:

如果对象存在则为True,否则为False。

Return type:

布尔值

put_file(file_path: PurePath, file: 文件) None[来源]#

将文件上传到对象存储。

Parameters:
  • file_path (PurePath) – 存储中对象的路径。

  • file (File) – 要上传的文件。

upload_file(local_file_path: Path, remote_file_path: PurePath) None[来源]#

将本地文件上传到对象存储。

Parameters:
  • local_file_path (Path) - 要上传的本地文件路径。

  • remote_file_path (PurePath) – 存储中对象的路径。

camel.storages.object_storages.google_cloud 模块#

class camel.storages.object_storages.google_cloud.GoogleCloudStorage(bucket_name: str, create_if_not_exists: bool = True, anonymous: bool = False)[来源]#

基础类: BaseObjectStorage

一个用于连接Google云存储的类。它将连接到存储账户中的一个存储桶。

请注意,Google Cloud Storage不支持API密钥认证。 因此,在使用此类之前,您需要先通过gcloud命令行工具登录并保存凭据。

Parameters:
  • bucket_name (str) - 存储桶的名称。

  • create_if_not_exists (bool, optional) – 如果存储桶不存在时是否创建它。默认为True。

  • anonymous (bool, optional) – 是否使用匿名访问。默认为False。

参考文献

https://cloud.google.com/storage

https://cloud.google.com/docs/authentication/api-keys

static canonicalize_path(file_path: PurePath) Tuple[str, str][来源]#

规范化Google云存储的路径。

Parameters:

file_path (PurePath) – 需要规范化的路径。

Returns:

规范化的文件键和文件名。

Return type:

元组[str, str]

模块内容#

class camel.storages.object_storages.AmazonS3Storage(bucket_name: str, create_if_not_exists: bool = True, access_key_id: str | None = None, secret_access_key: str | None = None, anonymous: bool = False)[来源]#

基础类: BaseObjectStorage

一个用于连接AWS S3对象存储的类,可从S3存储桶中存取对象。该类会首先尝试使用作为参数传入的凭证,如果未提供,则会查找环境变量AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY。如果这些凭证都未提供,它将尝试使用本地凭证(如果通过AWS CLI登录则会自动创建)。

Parameters:
  • bucket_name (str) - S3存储桶的名称。

  • create_if_not_exists (bool, optional) – 如果存储桶不存在,是否创建它。默认为True。

  • access_key_id (Optional[str], optional) – AWS访问密钥ID。 默认为None。

  • secret_access_key (Optional[str], optional) – AWS密钥访问密钥。 默认为None。

  • anonymous (bool, optional) – 是否使用匿名访问。默认为False。

参考文献

https://aws.amazon.com/pm/serv-s3/

https://aws.amazon.com/cli/

static canonicalize_path(file_path: PurePath) Tuple[str, str][来源]#

为Amazon S3规范化文件路径。

Parameters:

file_path (PurePath) – 需要规范化的路径。

Returns:

规范化的文件键和文件名。

Return type:

元组[str, str]

class camel.storages.object_storages.AzureBlobStorage(storage_account_name: str, container_name: str, create_if_not_exists: bool = True, access_key: str | None = None)[来源]#

基础类: BaseObjectStorage

一个用于连接Azure Blob Storage的类。它将连接到存储账户中的一个容器。

Parameters:
  • storage_account_name (str) - 存储账户的名称。

  • container_name (str) - 容器的名称。

  • access_key (Optional[str], optional) – 存储账户的访问密钥。默认为None。

参考文献

https://azure.microsoft.com/en-us/products/storage/blobs

static canonicalize_path(file_path: PurePath) Tuple[str, str][来源]#

规范化Azure Blob Storage的文件路径。

Parameters:

file_path (PurePath) – 需要规范化的路径。

Returns:

规范化的文件键和文件名。

Return type:

元组[str, str]

class camel.storages.object_storages.GoogleCloudStorage(bucket_name: str, create_if_not_exists: bool = True, anonymous: bool = False)[来源]#

基础类: BaseObjectStorage

一个用于连接Google云存储的类。它将连接到存储账户中的一个存储桶。

请注意,Google Cloud Storage不支持API密钥认证。 因此,在使用此类之前,您需要先通过gcloud命令行工具登录并保存凭据。

Parameters:
  • bucket_name (str) - 存储桶的名称。

  • create_if_not_exists (bool, optional) – 如果存储桶不存在,是否创建它。默认为True。

  • anonymous (bool, optional) – 是否使用匿名访问。默认为False。

参考文献

https://cloud.google.com/storage

https://cloud.google.com/docs/authentication/api-keys

static canonicalize_path(file_path: PurePath) Tuple[str, str][来源]#

规范化Google云存储的路径。

Parameters:

file_path (PurePath) – 需要规范化的路径。

Returns:

规范化的文件键和文件名。

Return type:

元组[str, str]