html - AWS S3-策略条件失败-eq 键
问题描述
我正在从网站上传文件到 s3。我从使用aws sdk
. 我遇到的问题是它生成了一个我必须在我的表单中使用的密钥,如下所示:
<input type="hidden" name="key" value="xxx" /><br />
它有效,但我上传的每个文件都有“密钥”的名称。如果我把它改成这样:
<input type="hidden" name="key" value="xxx/name.jpg" /><br />
它给了我一个错误:
Invalid according to Policy: Policy Condition failed: ["eq", "$key", "xxx"]
以下是我生成策略的条件:
Conditions: [
['starts-with', '$key', ''],
["starts-with", "$Content-Type", "image/"],
{"x-amz-server-side-encryption": "AES256"}
]
如何设置文件的名称?
解决方案
I solved it. The problem was that in parameters object which is passed this function:
s3.createPresignedPost(params, function(err, data)
I had parameter Fields which included key:
Fields: {
key: key,
},
Simply deleting it fixed the problem
推荐阅读
- php - PHP插入没有主键的json对象
- c# - 如果直到运行时才知道对象的名称,如何引用对象的属性?
- c# - 如何将列表字符串传递给 TempData Asp.Net
- javascript - 计算 typeof 值为 'object' 的属性在另一个对象中的数量
- angular - Angular 为什么我们需要 markForCheck 当 detectChanges 也有效时
- dart - 在 Dart 中禁用 print()
- c# - 如何避免 NGEN?
- ios - -thingWithContentsOfFile:与 NSPropertyListSerialization
- android - 如果背景是 ?android:attr/selectableItemBackground(AlertDialog 中的 ListView),如何使 View 看起来像是被编程选择
- vb.net - 如何在 vb.net 中使用数据填充 XML