建模程序 多个定时程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

24 lines
1.1 KiB

import os
import requests
#向 https://lenovodata.blob.core.windows.net/secretdata/photos/1/photo2/92_2.jpg?se=2025-10-30T10%3A01%3A13Z&sig=bv2KAPuNkYT5%2B4tNVMo53kWKIoniQaDkog27AYAXm4s%3D&sp=rcw&spr=https&sr=b&st=2025-10-30T09%3A01%3A13Z&sv=2025-05-05
# 上传图片
def upload_image(image_path):
url = 'https://lenovodata.blob.core.windows.net/secretdata/photos/1/photo2/92_2.jpg?se=2025-10-30T10%3A01%3A13Z&sig=bv2KAPuNkYT5%2B4tNVMo53kWKIoniQaDkog27AYAXm4s%3D&sp=rcw&spr=https&sr=b&st=2025-10-30T09%3A01%3A13Z&sv=2025-05-05'
with open(image_path, 'rb') as f:
image_data = f.read()
headers = {
'x-ms-blob-type': 'BlockBlob',
'Content-Type': 'image/jpeg',
}
response = requests.put(url, data=image_data, headers=headers)
try:
response.raise_for_status()
except requests.HTTPError as e:
raise RuntimeError(f'上传失败 {response.status_code}: {response.text}') from e
return {
'status_code': response.status_code,
'etag': response.headers.get('ETag'),
}
upload_image('273628Tex1.jpg')