This commit is contained in:
jxxghp
2024-11-16 10:55:17 +08:00
parent 665da9dad3
commit fc69d7e6c1
3 changed files with 9 additions and 3 deletions
+3 -2
View File
@@ -339,9 +339,10 @@ class MediaChain(ChainBase, metaclass=Singleton):
return
tmp_file = settings.TEMP_PATH / _path.name
tmp_file.write_bytes(_content)
logger.info(f"保存文件:【{_fileitem.storage}{_path}")
_fileitem.path = str(_path.parent)
self.storagechain.upload_file(fileitem=_fileitem, path=tmp_file)
item = self.storagechain.upload_file(fileitem=_fileitem, path=tmp_file)
if item:
logger.info(f"已保存文件:{item.path}")
if tmp_file.exists():
tmp_file.unlink()
+2 -1
View File
@@ -57,7 +57,8 @@ class StorageChain(ChainBase):
"""
return self.run_module("download_file", fileitem=fileitem, path=path)
def upload_file(self, fileitem: schemas.FileItem, path: Path, new_name: str = None) -> Optional[bool]:
def upload_file(self, fileitem: schemas.FileItem, path: Path,
new_name: str = None) -> Optional[schemas.FileItem]:
"""
上传文件
:param fileitem: 保存目录项