(self, file: UploadFile, save_path: str)
| 298 | ) |
| 299 | |
| 300 | async def save_file(self, file: UploadFile, save_path: str): |
| 301 | async with self._client() as s3: |
| 302 | # 使用 upload_fileobj 流式上传,避免将整个文件加载到内存 |
| 303 | await s3.upload_fileobj( |
| 304 | file.file, |
| 305 | self.bucket_name, |
| 306 | save_path, |
| 307 | ExtraArgs={"ContentType": file.content_type or "application/octet-stream"}, |
| 308 | ) |
| 309 | |
| 310 | async def delete_file(self, file_code: FileCodes): |
| 311 | async with self._client() as s3: |
no test coverage detected