1
我有蟒蛇的工作守則,文件上載到服務器與下面的代碼[R HTTR錯誤403
with open(file_path, 'rb') as fp:
r = requests.Request('PUT', signedRequest, data=fp.read())
prepped = r.prepare()
s = requests.Session()
resp = s.send(prepped)
在RI現在用的是下面的代碼,因爲它是替代
PUT(url = signedRequest,
body = upload_file(path = file_path),verbose()
)
但它是拋出錯誤
HTTP/1.1 403 Forbidden
在requestbin請求被接收爲
對於Python
Cf-Connecting-Ip: ****
Host: requestb.in
Connect-Time: 1
Total-Route-Time: 0
Via: 1.1 vegur
Content-Length: 6481350
Connection: close
Cf-Ipcountry: US
X-Request-Id: f9b165cc-0f42-4eaa-8b40-2eb37a6ff1ca
Accept-Encoding: gzip
Cf-Ray: 346d734353e871df-ORD
Cf-Visitor: {"scheme":"http"}
當R
Cf-Connecting-Ip: ****
Content-Length: 6481350
User-Agent: libcurl/7.47.0 r-curl/2.3 httr/1.2.1
Total-Route-Time: 0
Via: 1.1 vegur
Connection: close
Cf-Ipcountry: US
Content-Type: text/csv
X-Request-Id: 0bfbf6ab-4658-4650-bd4d-e1e19ffdba91
Accept: application/json, text/xml, application/xml, */*
Connect-Time: 0
Accept-Encoding: gzip
Host: requestb.in
Cf-Ray: 346d6e90d70f54ec-ORD
Cf-Visitor: {"scheme":"http"}
有什麼建議?
而不是張貼到真實的URL抑制用戶代理,您可以嘗試在Python和R等網站上發佈https://requestb.in/,以比較服務器看到的請求。您正在嘗試上傳的文件類型是什麼? – MrFlick
我想上傳一個.csv文件 – anonR
發佈了兩個輸出。 – anonR