The Minio Golang Client SDK provides simple APIs to access any Amazon S3 compatible object storage server.
List of supported cloud storage providers.
-
AWS Signature Version 4
- Amazon S3
- Minio
-
AWS Signature Version 2
- Google Cloud Storage (Compatibility Mode)
- Openstack Swift + Swift3 middleware
- Ceph Object Gateway
- Riak CS
This quickstart guide will show you how to install the client SDK and execute an example Golang program. For a complete list of APIs and examples, please take a look at the Golang Client API Reference documentation.
This document assumes that you have a working Golang setup in place.
$ go get -u github.com/minio/minio-go
You need four items in order to connect to Minio object storage server.
Params | Description |
---|---|
endpoint | URL to object storage service. |
accessKeyID | Access key is like user ID that uniquely identifies your account. |
secretAccessKey | Secret key is the password to your account. |
secure | Set this value to 'true' to enable secure (HTTPS) access. |
package main
import (
"fmt"
"github.com/minio/minio-go"
)
func main() {
// Use a secure connection.
ssl := true
// Initialize minio client object.
minioClient, err := minio.New("play.minio.io:9000", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", ssl)
if err != nil {
fmt.Println(err)
return
}
}
This example program connects to an object storage server, makes a bucket on the server and then uploads a file to the bucket.
We will use the Minio server running at https://play.minio.io:9000 in this example. Feel free to use this service for testing and development. Access credentials shown in this example are open to the public.
package main
import "fmt"
import (
"log"
"github.com/minio/minio-go"
)
func main() {
// Use a secure connection.
ssl := true
// Initialize minio client object.
minioClient, err := minio.New("play.minio.io:9000", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", ssl)
if err != nil {
log.Fatalln(err)
}
// Make a new bucket called mymusic.
err = minioClient.MakeBucket("mymusic", "us-east-1")
if err != nil {
log.Fatalln(err)
}
fmt.Println("Successfully created mymusic")
// Upload the zip file with FPutObject.
n, err := minioClient.FPutObject("mymusic", "golden-oldies.zip", "/tmp/golden-oldies.zip", "application/zip")
if err != nil {
log.Fatalln(err)
}
log.Printf("Successfully uploaded golden-oldies.zip of size %d\n", n)
}
$ go run file-uploader.go
$ Successfully created mymusic
$ Successfully uploaded golden-oldies.zip of size 17MiB
$ mc ls play/mymusic/
[2016-05-27 16:02:16 PDT] 17MiB golden-oldies.zip
The full API Reference is available here.
SetBucketNotification
GetBucketNotification
RemoveAllBucketNotification
ListenBucketNotification
(Minio Extension)
- listbuckets.go
- listobjects.go
- bucketexists.go
- makebucket.go
- removebucket.go
- listincompleteuploads.go
- setbucketnotification.go
- getbucketnotification.go
- deletebucketnotification.go
- listenbucketnotification.go (Minio Extension)