Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import mimetypes
- # 获取上传地址
- def get_url():
- response = requests.get('https://video-oss.vercel.app/link')
- return response.text
- def upload_file(file_path):
- url = get_url()
- # 打开文件
- with open(file_path, 'rb') as f:
- # 使用 PUT 方法上传文件
- requests.put(url, data=f, headers={
- 'Content-Type': 'image/jpeg'
- })
- print(f'上传成功: {url}?response-content-type={mimetypes.guess_type(file_path)[0]}')
- # 改成自己要上传的文件路径
- upload_file('image.gif')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement