feat(core.file): 新增 move_file

This commit is contained in:
han0
2023-03-22 10:00:44 +08:00
parent a8854edd92
commit edd6ea8dc7
2 changed files with 23 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import os
import shutil
import time
import requests
@@ -27,3 +28,20 @@ def save_file(f: FileStorage, path: str, namespace: str=None, filename: str=None
tmp_f.write(f.read())
return os.path.join(save_path, filename)
def move_file(file_path: str, path: str, namespace: str = None, filename: str = None) -> str:
if namespace:
save_path = os.path.join(path, namespace.replace('.', os.path.sep))
else:
save_path = path
if not os.path.exists(save_path):
os.makedirs(save_path)
filename = filename or '{}{}'.format(str(int(time.time() * 1000)), os.path.splitext(file_path)[-1])
target_file_path = os.path.join(save_path, filename)
shutil.move(file_path, target_file_path)
return target_file_path

4
upload.bat Normal file
View File

@@ -0,0 +1,4 @@
python36 -m pip install --upgrade setuptools wheel twine -i https://pypi.douban.com/simple
python36 setup.py sdist bdist_wheel
twine check dist/*
twine upload --repository-url http://192.168.12.2:8082/repository/pypi-hosted/ dist/*