AmazonS3:自定义错误页面

编程入门 行业动态 更新时间:2024-10-15 06:22:11
本文介绍了AmazonS3:自定义错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我计划共享私有对象的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:自定义错误页面

本文发布于:2023-11-03 18:59:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555824.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   错误   页面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!