让Amazon S3在缺少对象请求时重定向到我的终端节点? [英] Get Amazon S3 to redirect to my endpoint on missing object requests?
问题描述
我们使用S3进行文件在线存储.为了降低成本,可以按需使用事先已知的路径来生成许多这些文件.
We use S3 for online storage of files. To reduce costs, many of those files can be generated on demand with a path known ahead of time.
是否可以让S3存储桶将丢失的对象请求重定向到我预先配置的端点(然后可以按需生成并提供文件)?
Is it possible to get S3 bucket to redirect missing object requests to my pre-configured endpoint (which can then generate and serve the file on demand)?
例如,对 http://bucket1.s3.amazonaws.com/的请求path2/file3.jpg 会临时重定向(307)到 http://mydomain .com/missing_s3_obj/bucket1/path2/file3.jpg .
For example, a request to http://bucket1.s3.amazonaws.com/path2/file3.jpg would temporarily redirect (307) to http://mydomain.com/missing_s3_obj/bucket1/path2/file3.jpg.
推荐答案
You can use RoutingRules
to have S3 redirect to your domain as described in the Example 3 of Configure a Bucket for Website Hosting from the S3 documentation. I believe it describes your situation accurately.
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>mydomain.com</HostName>
<ReplaceKeyPrefixWith>missing_s3_obj/bucket1/</ReplaceKeyPrefixWith>
<HttpRedirectCode>307</HttpRedirectCode>
</Redirect>
</RoutingRule>
</RoutingRules>
这篇关于让Amazon S3在缺少对象请求时重定向到我的终端节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!