Configure S3 connection addressing modes
masterGoFakeS3 supports different addressing styles. Choosing the right one depends on your environment and client configuration.
1. Path-Style Addressing (Recommended)
In this mode, the bucket name is part of the URL path. This is the most flexible approach for local testing.
- URL Format:
http://localhost:9000/mybucket/myobject - AWS SDK v2 Configuration: Set
o.UsePathStyle = truein the client options. - AWS SDK v3 (JS) Configuration: Set
forcePathStyle: true. - AWS SDK v1 (JS) Configuration: Set
s3ForcePathStyle: true.
2. Virtual-Hosted Style Addressing
In this mode, the bucket name is part of the hostname.
- URL Format:
http://mybucket.localhost:9000/myobject - Requirement: Requires DNS configuration. If using
localhost, you must add entries to your/etc/hostsfile for every bucket used (e.g.,127.0.0.1 mybucket.localhost). - AWS SDK v2 Configuration: This is the default mode if
UsePathStyleis not set.
3. Environment Variable (AWS SDK v2)
For applications using the AWS SDK v2 that do not explicitly configure the endpoint in code, you can set the following environment variable:
AWS_ENDPOINT_URL_S3=http://localhost:9000