如何设置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屋!