1234567891011121314151617181920212223242526 |
- import hashlib
- import requests
- def download_file(file_url, local_file_path):
- reply = requests.get(file_url)
- with open(local_file_path, 'wb') as f:
- f.write(reply.content)
- def upload_file(file_name):
- data = {'file_path': file_name}
- reply = requests.post('https://127.0.0.1:5555/upload_file', data=data, files=data)
- return reply.json()
- def get_file_md5(file_path):
- md5 = hashlib.md5()
- with open(file_path, 'rb') as f:
- # 分块读取以支持大文件
- while chunk := f.read(8192):
- md5.update(chunk)
- return md5.hexdigest()
|