[使用REST API的AWS S3 PUT示例

问题描述 投票:0回答:1

AWS S3 PUT REST API docs在请求语法中缺少Authorization string的清晰示例。

Request Syntax

PUT /Key+ HTTP/1.1
Host: Bucket.s3.amazonaws.com
x-amz-acl: ACL
Cache-Control: CacheControl
Content-Disposition: ContentDisposition
Content-Encoding: ContentEncoding
Content-Language: ContentLanguage
Content-Length: ContentLength
Content-MD5: ContentMD5
Content-Type: ContentType
Expires: Expires
x-amz-grant-full-control: GrantFullControl
x-amz-grant-read: GrantRead
x-amz-grant-read-acp: GrantReadACP
x-amz-grant-write-acp: GrantWriteACP
x-amz-server-side-encryption: ServerSideEncryption
x-amz-storage-class: StorageClass
x-amz-website-redirect-location: WebsiteRedirectLocation
x-amz-server-side-encryption-customer-algorithm: SSECustomerAlgorithm
x-amz-server-side-encryption-customer-key: SSECustomerKey
x-amz-server-side-encryption-customer-key-MD5: SSECustomerKeyMD5
x-amz-server-side-encryption-aws-kms-key-id: SSEKMSKeyId
x-amz-server-side-encryption-context: SSEKMSEncryptionContext
x-amz-request-payer: RequestPayer
x-amz-tagging: Tagging
x-amz-object-lock-mode: ObjectLockMode
x-amz-object-lock-retain-until-date: ObjectLockRetainUntilDate
x-amz-object-lock-legal-hold: ObjectLockLegalHoldStatus

Body

文档将进一步在...上显示此请求示例...


PUT /my-image.jpg HTTP/1.1
Host: myBucket.s3.<Region>.amazonaws.com
Date: Wed, 12 Oct 2009 17:50:00 GMT
Authorization: authorization string
Content-Type: text/plain
Content-Length: 11434
x-amz-meta-author: Janet
Expect: 100-continue
[11434 bytes of object data]

但是同样,该文档没有Auth String的示例格式。我尝试了AccessKeyID Secret,但是没有用。我什至没有在请求语法中看到逻辑参数,以在示例中的任何地方传递证书的两个部分(AccessKeyID和Secret)!

没有人有一个简单的示例,说明如何使用PUT使用REST API将.json文件添加到S3吗?最好是PostMan设置的屏幕截图,以更好地解释值的位置(URL还是标题)。

amazon-web-services rest amazon-s3 put
1个回答
1
投票

From the AWS docs here,看来仅使用REST API即可向S3存储桶创建PUT请求是[[not:

For authenticated requests, unless you are using the AWS SDKs, you have to write code to calculate signatures that provide authentication information in your requests.
这对我来说是个新概念。通过REST API进行身份验证之前,我已经使用了令牌请求并在标头中发送了密钥。听起来像是一种更安全的身份验证方法。    
© www.soinside.com 2019 - 2024. All rights reserved.