feat(core.file): 新增 move_file
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
|
||||
import requests
|
||||
@@ -12,7 +13,7 @@ def download_file(url: str, path: str) -> str:
|
||||
return path
|
||||
|
||||
|
||||
def save_file(f: FileStorage, path: str, namespace: str=None, filename: str=None) -> str:
|
||||
def save_file(f: FileStorage, path: str, namespace: str = None, filename: str = None) -> str:
|
||||
if namespace:
|
||||
save_path = os.path.join(path, namespace.replace('.', os.path.sep))
|
||||
else:
|
||||
@@ -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
4
upload.bat
Normal 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/*
|
Reference in New Issue
Block a user