0
我试图找到一种方法来更改上传到s3存储桶时使用的http方法(POST/PUT)与boto3 python的库,我一直无法找到如何做到这一点,任何帮助将不胜感激。如何更改boto3中的http方法
谢谢。
我试图找到一种方法来更改上传到s3存储桶时使用的http方法(POST/PUT)与boto3 python的库,我一直无法找到如何做到这一点,任何帮助将不胜感激。如何更改boto3中的http方法
谢谢。
为此,您需要注册event。您可以在botocore中看到一个示例。我很好奇你为什么想要这样做,因为它只会让你的表单变得更加困难,因为它强制你编码请求,就好像它是从HTML表单提交的一样。
复制为后人:
def change_get_to_post(request, **kwargs):
# This is useful when we need to change a potentially large GET request
# into a POST with x-www-form-urlencoded encoding.
if request.method == 'GET' and '?' in request.url:
request.headers['Content-Type'] = 'application/x-www-form-urlencoded'
request.method = 'POST'
request.url, request.data = request.url.split('?', 1)
事实证明,帖子没有在boto3中实现,所以这是一种方法,或者只是使用请求来实现整个事情。谢谢。 – Miguel
什么让你觉得POST是支持S3桶?我的理解是HTTP动词被boto3封装为's3.Object().get()','s3.Object.put()'等,并根据文档(http://boto3.readthedocs .org/en/latest/reference/services/s3.html#object)post()未实现。 –
POST是[supported](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html),但我没有任何理由在浏览器之外使用它。 –