【问题标题】:How to pass encoded Amazon s3 signed URL in python curl Postfields?如何在 python curl Postfields 中传递编码的 Amazon s3 签名 URL?
【发布时间】:2017-03-08 12:03:24
【问题描述】:

我需要将亚马逊 s3 签名 URL 传递给我的 python cURL 函数。签名的 url 有一些特殊字符作为 '%' 被传递给 cURL POSTFIELDS 并且在处理之后我得到 500 Internal Server 错误。有没有办法以编码格式传递 POSTFIELDS 以便 cURL 可以处理它?

【问题讨论】:

    标签: python curl amazon-s3 pycurl


    【解决方案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)
    

    【讨论】:

      猜你喜欢
      • 2021-12-10
      • 2018-12-27
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-18
      • 1970-01-01
      相关资源
      最近更新 更多