MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / save_chunk

Method save_chunk

core/storage.py:401–417  ·  view source on GitHub ↗

保存分片到 S3(使用独立对象存储每个分片) 注意:这里不使用 S3 原生的 multipart upload,而是将每个分片作为独立对象存储

(self, upload_id: str, chunk_index: int, chunk_data: bytes, chunk_hash: str, save_path: str)

Source from the content-addressed store, hash-verified

399 return result
400
401 async def save_chunk(self, upload_id: str, chunk_index: int, chunk_data: bytes, chunk_hash: str, save_path: str):
402 """
403 保存分片到 S3(使用独立对象存储每个分片)
404 注意:这里不使用 S3 原生的 multipart upload,而是将每个分片作为独立对象存储
405 """
406 chunk_key = str(Path(save_path).parent / "chunks" / upload_id / f"{chunk_index}.part")
407 async with self._client() as s3:
408 # 将分片作为独立对象上传
409 await s3.put_object(
410 Bucket=self.bucket_name,
411 Key=chunk_key,
412 Body=chunk_data,
413 Metadata={
414 'chunk-hash': chunk_hash,
415 'chunk-index': str(chunk_index)
416 }
417 )
418
419 async def merge_chunks(self, upload_id: str, chunk_info: UploadChunk, save_path: str) -> tuple[str, str]:
420 """

Callers 1

upload_chunkFunction · 0.45

Calls 1

_clientMethod · 0.95

Tested by

no test coverage detected