[英]python upload file with curl
i'm trying to upload an apk to server the code i used to upload using curl is written like this: 我正在尝试将apk上传到服务器,而我以前使用curl上传的代码是这样写的:
curl -u "musername:mypass" -X POST "https://myurl/upload" -F "file=@D:\path\to\location.apk"
i tried to make a script using python with requests
library like this: 我试图使用带有requests
库的python创建脚本,如下所示:
response = requests.post(
self.urlUpload,
files={"file" : open(self.apkLocation, 'r')},
auth=(self.BSUsername, self.BSToken)
)
but it gives me errors: 但这给了我错误:
{"error":"Malformed archive"}
anyone knows why this erros appeared? 有谁知道为什么出现这种错误?
Have you had a chance to try something like below? 您是否有机会尝试以下类似方法?
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
Check the BrowserStack REST API doc here 在此处查看BrowserStack REST API文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.