diff --git a/nc_http/core/file/func.py b/nc_http/core/file/func.py index b571dcc..1246a26 100644 --- a/nc_http/core/file/func.py +++ b/nc_http/core/file/func.py @@ -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 diff --git a/upload.bat b/upload.bat new file mode 100644 index 0000000..1ac6c12 --- /dev/null +++ b/upload.bat @@ -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/* \ No newline at end of file