首页 > 其他分享 >转载:上传文件

转载:上传文件

时间:2022-11-10 17:23:47浏览次数:45  
标签:文件 refreshToken accessToken url data Content json 转载 上传

转载:https://www.jb51.net/article/216739.htm 

 我的源代码如下,但是有问题的哦,还没有找到原因!

import json

import requests
#登录系统,并取到token值

url = 'http://test.xxxx.com:8060/api/gv-op/userAuth/login'
header = {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36"
}
data = {"account": "guest_Pai_shz","password": "PW_Pai_shz"}
res = requests.post(url=url, headers=header, data=json.dumps(data))
tt = json.loads(res.text)
refreshToken = tt["data"]["refreshToken"]
accessToken = tt["data"]["accessToken"]
print(accessToken)
print(refreshToken)
#上传文件
header2={
'accessToken':accessToken,
'refreshToken':refreshToken
}
up_url='http://test.lxxxxom:8060/api/gv-op/deviceVersion/info'

files={'file':open('D:\\210508_OTAfront.bin','rb'),
'Content-Type': 'application/octet-stream',
'Content-Disposition': 'form-data'
}
data2_value={
"description":"aad","deviceModel":"407","firmwareVersion":"ccfd","hardwareVersion":"bb","updateDescription":"dddd",
'Content-Disposition': 'form-data','name':"file",'filename':'210508_OTAfront.bin'
}
data2={
'deviceVersion':data2_value
}
res2=requests.post(url=up_url,headers=header2,data=data2,files=files)
# print(json.loads(res2.text))

 

 

标签:文件,refreshToken,accessToken,url,data,Content,json,转载,上传
From: https://www.cnblogs.com/suhongzhen/p/16877738.html

相关文章