如何更改boto3中的http方法

How to change the http method in boto3

我正在尝试找到一种方法来更改使用 boto3 python 库上传到 s3 存储桶时使用的 http 方法 (POST/PUT),但我无法做到找到一种方法来做到这一点,任何帮助将不胜感激。

谢谢。

为此,您需要注册一个 event. You can see an example where this is done in 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)