如何格式化 URL 以从 Amazon S3 获取文件? [英] How to format a URL to get a file from Amazon S3?
问题描述
我在弄清楚如何从 Amazon S3 访问文件时遇到了一些麻烦.假设文件所在的存储桶是 BUCKET_NAME
,文件是 FILE_NAME
等.我尝试了以下两个 URL:
I am having some trouble figuring out how to access a file from Amazon S3. Lets say that the bucket that the file lives in is BUCKET_NAME
, the file is FILE_NAME
, etc. I have tried the following two URLs:
https://s3.amazonaws.com/BUCKET_NAME/FILE_NAME/
?Expires=EXPIRATION
&Signature=SIGNATURE
&SignatureVersion=2
&SignatureMethod=HmacSHA1
&AWSAccessKeyId=KEYID
但这给了我以下错误:
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
我也试过:
https://s3.amazonaws.com/BUCKET_NAME/
?Key=FILE_NAME
&Expires=EXPIRATION
&Signature=SIGNATURE
&SignatureVersion=2
&SignatureMethod=HmacSHA1
&AWSAccessKeyId=KEYID
但这会返回一个网页,其中包含给定存储桶中所有文件的列表(包括 FILE_NAME
),而不是我想要的特定文件.我还尝试将 Action=GetObject
也放入 URL 中,但这似乎没有任何改变.
but this returns a webpage with a list of all of the files in the given bucket (including FILE_NAME
), instead of the specific file I want. I have also tried throwing in Action=GetObject
into the URL as well but that doesn't seem to change anything.
找出哪种(如果有)是正确的方法以及我做错了什么会很有帮助.我一直在挖掘亚马逊的文档一段时间,但我似乎无法解决它.
It would be helpful to find out which (if any) is the proper method and what I am doing wrong. I have been digging through Amazon's documentation for a while now but I can't seem to sort it out.
推荐答案
它实际上更像是:
https://<bucket-name>.s3.amazonaws.com/<key>
请参阅此处
这篇关于如何格式化 URL 以从 Amazon S3 获取文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!