从 SDK 重定向到 S3 存储桶

Redirect for S3 bucket from SDK

我有几个函数可以在 S3 上创建 2 个存储桶,一个用于 example.com,另一个用于 www.example.com。我需要知道应该使用什么来启用第二个存储桶,以便它重定向到第一个存储桶。

example of how to set it in the backend

我的问题是我需要能够使用 SDK 执行此操作。

谢谢,

相关的 API 调用是 AWS.S3.putBucketWebsite

文档中的相关部分:

var params = {
    /** truncated **/
    RedirectAllRequestsTo: {
      HostName: 'STRING_VALUE', /* required */
      Protocol: 'http | https'
    },

Redirect — required — (map) Container for redirect information. You can redirect requests to another host, to another page, or with another protocol. In the event of an error, you can can specify a different error code to return.