2021-06-10 11:17:03 -04:00
|
|
|
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{
|
2021-06-14 14:04:14 -04:00
|
|
|
Creds: credentials.NewStaticV4("access-key", "secret-key", ""),
|
2021-06-10 11:17:03 -04:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
2021-06-14 14:04:14 -04:00
|
|
|
var opts minio.GetObjectOptions
|
|
|
|
|
|
|
|
// Add extract header to request:
|
|
|
|
opts.Set("x-minio-extract", "true")
|
|
|
|
|
2021-06-10 11:17:03 -04:00
|
|
|
// Download API.md from the archive
|
2021-06-14 14:04:14 -04:00
|
|
|
rd, err := s3Client.GetObject(context.Background(), "your-bucket", "path/to/file.zip/data.csv", opts)
|
2021-06-10 11:17:03 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
_, err = io.Copy(os.Stdout, rd)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
}
|