[英]python upload file with curl
我正在嘗試將apk上傳到服務器,而我以前使用curl上傳的代碼是這樣寫的:
curl -u "musername:mypass" -X POST "https://myurl/upload" -F "file=@D:\path\to\location.apk"
我試圖使用帶有requests
庫的python創建腳本,如下所示:
response = requests.post(
self.urlUpload,
files={"file" : open(self.apkLocation, 'r')},
auth=(self.BSUsername, self.BSToken)
)
但這給了我錯誤:
{"error":"Malformed archive"}
有誰知道為什么出現這種錯誤?
您是否有機會嘗試以下類似方法?
import requests
files = {
'file': ('/path/to/app/file/Application-debug.apk', open('/path/to/app/file/Application-debug.apk', 'rb')),
}
response = requests.post('https://api-cloud.browserstack.com/app-automate/upload',
files=files,
auth=('BSUsername ', 'BSToken'))
print (response.text)#THE APP URL (bs://<hashed appid>) RETURNED IN THE RESPONSE OF THIE CALL
在此處查看BrowserStack REST API文檔
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.