让Amazon S3在缺少对象请求时重定向到我的终端节点? [英] Get Amazon S3 to redirect to my endpoint on missing object requests?

查看:125
本文介绍了让Amazon S3在缺少对象请求时重定向到我的终端节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用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.

推荐答案

您可以使用RoutingRules使S3重定向到您的域,如

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆