I created a bucket, where I allow objects to be publicly accessible. I put a file in that bucket, and I can access it through a simple HTTP GET request (even from an anonymous browser). However, trying to access the same file using the AWS SDK for .net's GetObject function (or even using AWS CLI) I get an access denied error. What could I be doing wrong?
Private region As RegionEndpoint = RegionEndpoint.EUCentral1
Public Function ReadObject(ByVal bucket As String, ByVal key As String) As String
Dim request As New GetObjectRequest()
request.BucketName = bucket
request.Key = key
Dim responseBody As String
Dim client As New AmazonS3Client(region)
Using response As GetObjectResponse = client.GetObject(request)
Using responseStream As Stream = response.ResponseStream
Using reader As New StreamReader(responseStream)
responseBody = reader.ReadToEnd()
End Using
End Using
End Using
Return responseBody
End Function