gpt4 book ai didi

javascript - 根据策略 : Policy Condition failed: ["eq", "$success_action_redirect", "http://localhost/",AccessDenied 无效]

转载 作者:行者123 更新时间:2023-11-30 05:37:11 25 4
gpt4 key购买 nike

我正在尝试将图像上传到 Amazon S3 存储桶,但出现如下错误

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Invalid according to Policy: Policy Condition failed: ["eq", "$success_action_redirect", "LOCALHOST"]</Message>

这是我的政策:

POLICY_JSON = {'expiration': '20020-01-01T00:00:00Z',    'conditions': [    {'bucket': 'S3-bucket'},    ['starts-with', '$key', 'uploads/${filename}'],    {'acl': 'private'},    {'success_action_redirect': 'LOCALHOST'},    ['starts-with', '$Content-Type', ' '],    ['content-length-range', 0, 1048576]    ]    };

谁能帮帮我?我该如何解决这个问题?

最佳答案

不确定这是否相关,但我发现您的政策存在语法错误。我在 http://www.jsoneditoronline.org/ 上试过了

在您的政策中,我必须将所有 ' 替换为 " 然后我才能正常验证它。

所以这是将 ' 替换为 " 后的策略

{"expiration":"20020-01-01T00:00:00Z","conditions":[{"bucket":"S3-bucket"},["starts-with","$key","uploads/${filename}"],{"acl":"private"},{"success_action_redirect":"LOCALHOST"},["starts-with","$Content-Type"," "],["content-length-range",0,1048576]]}

或缩进:

{
"expiration": "20020-01-01T00:00:00Z",
"conditions": [
{
"bucket": "S3-bucket"
},
[
"starts-with",
"$key",
"uploads/${filename}"
],
{
"acl": "private"
},
{
"success_action_redirect": "LOCALHOST"
},
[
"starts-with",
"$Content-Type",
" "
],
[
"content-length-range",
0,
1048576
]
]
}

关于javascript - 根据策略 : Policy Condition failed: ["eq", "$success_action_redirect", "http://localhost/",AccessDenied 无效],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22981741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com