taolib.testing.file_storage.services.file_service#

文件服务。

提供文件上传、下载和元数据管理的业务逻辑。

Classes#

FileService

文件管理服务。

Module Contents#

class taolib.testing.file_storage.services.file_service.FileService(file_repo: taolib.testing.file_storage.repository.file_repo.FileRepository, bucket_repo: taolib.testing.file_storage.repository.bucket_repo.BucketRepository, thumbnail_repo: taolib.testing.file_storage.repository.thumbnail_repo.ThumbnailRepository, storage_backend: taolib.testing.file_storage.storage.protocols.StorageBackendProtocol, pipeline: taolib.testing.file_storage.processing.pipeline.ProcessingPipeline, cdn_provider: taolib.testing.file_storage.cdn.protocols.CDNProviderProtocol | None = None)#

文件管理服务。

_file_repo#
_bucket_repo#
_thumbnail_repo#
_storage_backend#
_pipeline#
_cdn_provider = None#
async upload_file(bucket_id: str, object_key: str, data: bytes, filename: str, content_type: str, user_id: str = 'system', access_level: taolib.testing.file_storage.models.enums.AccessLevel = AccessLevel.PRIVATE, tags: list[str] | None = None, custom_metadata: dict[str, str] | None = None) taolib.testing.file_storage.models.file.FileMetadataResponse#

上传文件(简单上传,适用于小文件)。

async get_file(file_id: str) taolib.testing.file_storage.models.file.FileMetadataResponse | None#

获取文件元数据。

async download_file(file_id: str) collections.abc.AsyncIterator[bytes]#

下载文件(流式)。

async update_metadata(file_id: str, data: taolib.testing.file_storage.models.file.FileMetadataUpdate, user_id: str = 'system') taolib.testing.file_storage.models.file.FileMetadataResponse | None#

更新文件元数据。

async delete_file(file_id: str, user_id: str = 'system') bool#

删除文件。

async list_files(bucket_id: str | None = None, prefix: str | None = None, tags: list[str] | None = None, media_type: str | None = None, skip: int = 0, limit: int = 100) list[taolib.testing.file_storage.models.file.FileMetadataResponse]#

列出文件。

async get_file_url(file_id: str, expires_in: int = 3600) str#

获取文件访问 URL。