/minio-go

Minio Go Library for Amazon S3 compatible cloud storage

Primary LanguageGoApache License 2.0Apache-2.0

Minio Golang Library for Amazon S3 Compatible Cloud Storage Gitter

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.

Download from Github

$ go get -u github.com/minio/minio-go

Initialize Minio Client

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
        }
}

Quick Start Example - File Uploader

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.

FileUploader.go

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)
}

Run FileUploader

$ 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

API Reference

The full API Reference is available here.

API Reference : Bucket Operations

API Reference : Bucket policy Operations

API Reference : Bucket notification Operations

API Reference : File Object Operations

API Reference : Object Operations

API Reference : Presigned Operations

Full Examples

Full Examples : Bucket Operations

Full Examples : Bucket policy Operations

Full Examples : Bucket notification Operations

Full Examples : File Object Operations

Full Examples : Object Operations

Full Examples : Presigned Operations

Explore Further

Contribute

Contributors Guide

Build Status Build status