我正在尝试将以下curl代码转换为pycurl。我不想使用请求。我需要使用pycurl。
curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" -F file=@local-folder/test.txt -F parent_dir=/path-in-seafile-repo/ -F replace=1 http://cloud.seafile.com:8082/upload-api/73c5d117-3bcf-48a0-aa2a-3f48d5274ae3
现在我有这个
from io import BytesIO
import pycurl
post_url = http://cloud.seafile.com:8082/upload-api/73c5d117-3bcf-48a0-aa2a-3f48d5274ae3
storage = BytesIO()
c = pycurl.Curl()
c.setopt(pycurl.URL, post_url)
c.setopt(pycurl.HTTPHEADER, ['Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd'])
c.setopt(pycurl.HTTPHEADER, ['parent_dir=/vinny/'])
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.HTTPPOST, [("file",(c.FORM_FILE, "D:\\large_file\\2.txt"))])
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.SSL_VERIFYHOST, 0)
c.setopt(pycurl.WRITEFUNCTION, storage.write)
c.perform()
c.close()
content = storage.getvalue()
text_value = content.decode('UTF-8')
print (text_value)
这个地方的问题“ parent_dir = / path-in-seafile-repo /”如何将其添加到pycurl代码中?