第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python怎么執(zhí)行curl -T命令?

Python怎么執(zhí)行curl -T命令?

阿晨1998 2019-02-18 15:42:36
curl -v 'https://developer.api.autodesk.com/oss/v2/buckets/mybucket/objects/example.txt' -X 'PUT' -H 'Authorization: Bearer AlmsGlZlqz1JkkzEruUdINMKA6IF' -H 'Content-Type: text/plain; charset=UTF-8' -T 'example.txt' 這是froge平臺上提供的一個curl傳文件的命令,用Python怎么解決呢https://forge.autodesk.com/en...:bucketKey-objects-:objectName-PUT/#body-structure。 我用urllib2實(shí)現(xiàn)的代碼,不知道怎么傳。 f = codecs.open(file_name, 'rb') filebody = f.read() PostUrl = ' https://developer.api.autodesk.com/oss/v2/buckets/'+bucketKey+'/objects/'+fileinfo.name bodys = {} bodys[''] = filebody postData = bodys # postData = {"file": filebody} headers = {'Authorization':'Bearer '+token,'Content-Length':fileinfo._size} request = urllib2.Request(PostUrl,postData) request.add_header('Authorization','Bearer '+token) request.add_header('Content-Length',fileinfo._size) request.get_method = lambda:'PUT' ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE response = urllib2.urlopen(request,context=ctx) result = response.read() result = eval(result) print '------', result response_data["results"] = result 報錯: Traceback (most recent call last): File "D:\ZZKJPRO\WuhanPro\src\modalManager\views.py", line 707, in autodesk_up loadfile response = urllib2.urlopen(request,context=ctx) File "C:\Python27\lib\urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "C:\Python27\lib\urllib2.py", line 429, in open response = self._open(req, data) File "C:\Python27\lib\urllib2.py", line 447, in _open '_open', req) File "C:\Python27\lib\urllib2.py", line 407, in _call_chain result = func(*args) File "C:\Python27\lib\urllib2.py", line 1241, in https_open context=self._context) File "C:\Python27\lib\urllib2.py", line 1195, in do_open h.request(req.get_method(), req.get_selector(), req.data, headers) File "C:\Python27\lib\httplib.py", line 1042, in request self._send_request(method, url, body, headers) File "C:\Python27\lib\httplib.py", line 1082, in _send_request self.endheaders(body) File "C:\Python27\lib\httplib.py", line 1038, in endheaders self._send_output(message_body) File "C:\Python27\lib\httplib.py", line 886, in _send_output self.send(message_body) File "C:\Python27\lib\httplib.py", line 858, in send self.sock.sendall(data) File "C:\Python27\lib\ssl.py", line 753, in sendall v = self.send(data[count:]) TypeError: unhashable type
查看完整描述

2 回答

?
瀟瀟雨雨

TA貢獻(xiàn)1833條經(jīng)驗(yàn) 獲得超4個贊

postData有問題, 直接令postData=f就好

查看完整回答
反對 回復(fù) 2019-03-01
  • 2 回答
  • 0 關(guān)注
  • 948 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號