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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南