Search code examples
goamazon-s3aws-sdk-go

Use path-style amazon aws sdk go


I'm using some aws-sdk-go functionalities in my app, and it creates DNS style hosts to request, like somebucket.mys3.com. But I have some DNS issues and want to receive the requests in path-style, like mys3.com/somebucket. How can I config the SDK to generates it requests in path-style mode?


Solution

  • In the aws.Config set the S3ForcePathStyle to true, ie

    ses, err := session.NewSession(
       &aws.Config{
          S3ForcePathStyle: aws.Bool(true),
          ...
       }
    )