如何在python curl Postfields中传递编码的Amazon s3签名URL?

时间:2017-03-08 12:03:25

标签: python curl amazon-s3 pycurl

我需要将一个亚马逊s3签名的URL传递给我的python cURL函数。已签名的网址包含一些特殊字符,如&#39;%&#39;这是传递给cURL POSTFIELDS并在处理后我得到500内部服务器错误。有没有办法以编码格式传递POSTFIELDS,以便cURL可以处理它?<​​/ p>

1 个答案:

答案 0 :(得分:1)

import urllib
import pycurl

def urlconvert:
  wrapper = {'filename':p} # p is the amazon s3 signed url
  c = pycurl.Curl()
  c.setopt(pycurl.URL, url) #url is the url for curl request
  c.setopt(pycurl.POST, 1)
  post_args = urllib.urlencode(wrapper)
  c.setopt(pycurl.POSTFIELDS, post_args)