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

asked 5 years ago618 views
1 Answer
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.

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions