0

我创建了一个存储桶,允许在其中公开访问对象。我在该存储桶中放置了一个文件,我可以通过一个简单的 HTTP GET 请求(甚至来自匿名浏览器)访问它。但是,尝试使用适用于 .net 的 AWS 开发工具包的 GetObject 函数(甚至使用 AWS CLI)访问同一文件时,我会收到拒绝访问错误。我可能做错了什么?

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
4

0 回答 0