minio/docs/extensions/s3zip/examples/minio-go/main.go
Klaus Post 0d1d26a4ea
Simplify s3zip example (#12500)
There is no need to create a custom transport wrapper.

Just set the header in the options.
2021-06-14 11:04:14 -07:00

36 lines
694 B
Go

package main
import (
"context"
"io"
"log"
"os"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
)
func main() {
s3Client, err := minio.New("minio-server-address:9000", &minio.Options{
Creds: credentials.NewStaticV4("access-key", "secret-key", ""),
})
if err != nil {
log.Fatalln(err)
}
var opts minio.GetObjectOptions
// Add extract header to request:
opts.Set("x-minio-extract", "true")
// Download API.md from the archive
rd, err := s3Client.GetObject(context.Background(), "your-bucket", "path/to/file.zip/data.csv", opts)
if err != nil {
log.Fatalln(err)
}
_, err = io.Copy(os.Stdout, rd)
if err != nil {
log.Fatalln(err)
}
}