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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠