Demonstrates using testcontainers-floci-go to test S3 operations against a local Floci instance.
The test:
- Starts a Floci container
- Creates an S3 bucket
- Uploads two documents (
hello.txt,world.txt) - Lists objects in the bucket
- Downloads and verifies the content of
hello.txt
go test -v -timeout 300s ./examples/s3/...// Start Floci
fc, err := floci.Run(ctx)
defer fc.Stop(ctx)
// Wire up the AWS SDK S3 client
cfg, _ := config.LoadDefaultConfig(ctx,
config.WithRegion(fc.GetRegion()),
config.WithBaseEndpoint(fc.GetEndpoint()),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
fc.GetAccessKey(), fc.GetSecretKey(), "",
)),
)
client := s3.NewFromConfig(cfg, func(o *s3.Options) {
o.UsePathStyle = true // required for local endpoints
})
UsePathStyle = trueis required when pointing the AWS SDK at a local endpoint.