Sab*_*ena 3 javascript http-post amazon-s3 amazon-web-services node.js
我有一个用于将文件上传到AWS s3的Node程序,我需要使用请求标头指定x-amz-tagging。我尝试了一些东西,但是没有用!
function buildRequestHeader() {
return {
'Content-Length': fileBuffer.size,
'Content-Type': mimeType,
'x-amz-acl': 'public-read',
'x-amz-tagging' :{"tag1":'abcd',"tag2":'efgh'}
}
}Run Code Online (Sandbox Code Playgroud)
我已经从AWS文档中看到了一些东西,
PUT object-key?tagging HTTP/1.1
Host: examplebucket.s3.amazonaws.com
Content-Length: length
Content-MD5: pUNXr/BjKK5G2UKExample==
x-amz-date: 20160923T001956Z
Authorization: authorization string
<Tagging>
<TagSet>
<Tag>
<Key>tag1</Key>
<Value>val1</Value>
</Tag>
<Tag>
<Key>tag2</Key>
<Value>val2</Value>
</Tag>
</TagSet>
</Tagging>Run Code Online (Sandbox Code Playgroud)
您能解释一下它是如何工作的吗?
The code snippets you show are from two different methods of tagging, the first during object creation, the second is adding tags to an existing object.
The x-amz-tagging header is what you would use during object creation, but it uses a different syntax than in your example. Try this instead:
function buildRequestHeader() {
return {
'Content-Length': fileBuffer.size,
'Content-Type': mimeType,
'x-amz-acl': 'public-read',
'x-amz-tagging': 'tag1=abcd&tag2=efgh'
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1397 次 |
| 最近记录: |