Object metadata x-amz-website-redirect-location not working via API

0

I have an object that has been added to a hosted bucket and has the correct x-amz-website-redirect-location metadata key added with a correct value. Cloudfront is not involved.

When I go to the console and look at the object properties I can verify everything looks good. When I request the object using the correct syntax <bucketname>.amazonaws.com/key the redirect does not fire. No error just blank page.

If I go to the console and add the key interactively it adds a slightly different metadata key called Website-Redirect-Location (not x-amz-website-redirect-location) and this works once added.

This is the first time I have attempted to do an object redirect. It seems to me these methods should be equivalent, but they are not yielding the same results. I tried adding the Website-Redirect-Location via API but it gets translated to x-amz-website-redirect-location during the call and doesn't work.

I need to be able to handle all of the from the .net api instead of console. Is there something else I may be missing here? I have searched on this topic and have verified the syntax for the keys and the urls are correct as well as bucket addressing. Thanks in advance.

Thanks.
Dave

質問済み 5年前651ビュー
1回答
0

So to hopefully assist someone else who runs into this. It turns out that when using the .Net API to add a redirect, you DO NOT add the metadata manually via a putRequest2.Metadata.Add("Website-Redirect-Location", URL) call as the documentation would lead you to believe.

Instead, add the WebsiteRedirectLocation = URL option to the PutObjectRequest. This works just fine.

Hope this saves the next person some time.

回答済み 5年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ