taolib.testing.file_storage.services.upload_service#

分片上传服务。

编排大文件分片上传流程。

Classes#

UploadService

分片上传服务。

Module Contents#

class taolib.testing.file_storage.services.upload_service.UploadService(upload_repo: taolib.testing.file_storage.repository.upload_repo.UploadSessionRepository, chunk_repo: taolib.testing.file_storage.repository.chunk_repo.ChunkRepository, file_repo: taolib.testing.file_storage.repository.file_repo.FileRepository, bucket_repo: taolib.testing.file_storage.repository.bucket_repo.BucketRepository, storage_backend: taolib.testing.file_storage.storage.protocols.StorageBackendProtocol, upload_session_ttl_hours: int = 24)#

分片上传服务。

_upload_repo#
_chunk_repo#
_file_repo#
_bucket_repo#
_storage_backend#
_ttl_hours = 24#
async init_upload(data: taolib.testing.file_storage.models.upload.UploadSessionCreate, user_id: str = 'system') taolib.testing.file_storage.models.upload.UploadSessionResponse#

初始化分片上传会话。

async upload_chunk(session_id: str, chunk_index: int, data: bytes, checksum: str | None = None) taolib.testing.file_storage.models.upload.ChunkRecord#

上传分片。

async complete_upload(session_id: str, user_id: str = 'system') taolib.testing.file_storage.models.file.FileMetadataResponse#

完成分片上传。

async abort_upload(session_id: str) bool#

中止分片上传。

async get_upload_status(session_id: str) taolib.testing.file_storage.models.upload.UploadSessionResponse | None#

获取上传状态。

async cleanup_expired_sessions() int#

清理过期的上传会话。