我计划共享私有对象的URL(限时).有没有一种方法可以为404/403 http响应设置自定义错误页面?
I am planning to share URLs (time limited) for private objects. Is there a way to set custom error pages for 404/403 http responses ?
推荐答案是的,有可能,请参见此公告. 在开发人员指南中,有一段有关自定义错误文档支持"中的以下句子.
Yes, it's possible, see this announcement. In the Developer guide there is a paragraph about "Custom Error Document Support" where I read the following sentence.
您可以选择提供自定义 用户友好的错误文档 错误消息以及其他 帮助.您提供此自定义错误 文档作为添加网站的一部分 配置到您的存储桶.亚马逊 S3返回您的自定义错误文档 仅针对HTTP 4XX类错误 代码.
You can optionally provide a custom error document with a user-friendly error message and with additional help. You provide this custom error document as part of adding website configuration to your bucket. Amazon S3 returns your custom error document for only the HTTP 4XX class of error codes.
如何设置4xx自定义错误页面:
How to set 4xx custom error page:
-
使用 CloudBerry ,您可以右键单击存储桶,选择属性",单击网站"标签并设置索引文档和4xx错误文档.
With CloudBerry, you can right click on a bucket, select Properties, click the tab Website and set the index document and the 4xx error document.
使用 AWS Java SDK ,这是示例代码(未经测试)
Use AWS Java SDK, here is an example code (not tested)
AmazonS3 client = new AmazonS3Client(new BasicAWSCredentials( "accessKey", "secretKey"); BucketWebsiteConfiguration conf = new BucketWebsiteConfiguration( "index.html", "404.html"); client.setBucketWebsiteConfiguration("bucketname.example", conf);
更新我也发现了此博客文章:在Amazon S3上托管您的静态网站.
UPDATE I also found this blog post: Host Your Static Website on Amazon S3.
更多推荐
AmazonS3:自定义错误页面
发布评论