Categorygithub.com/minio/minio-go
modulepackage
3.0.2+incompatible
Repository: https://github.com/minio/minio-go.git
Documentation: pkg.go.dev

# README

Minio Go Client SDK for Amazon S3 Compatible Cloud Storage Slack Sourcegraph

The Minio Go Client SDK provides simple APIs to access any Amazon S3 compatible object storage.

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 Minio client SDK, connect to Minio, and provide a walkthrough for a simple file uploader. For a complete list of APIs and examples, please take a look at the Go Client API Reference.

This document assumes that you have a working Go development environment.

Download from Github

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

Initialize Minio Client

Minio client requires the following four parameters specified to connect to an Amazon S3 compatible object storage.

ParameterDescription
endpointURL to object storage service.
accessKeyIDAccess key is the user ID that uniquely identifies your account.
secretAccessKeySecret key is the password to your account.
secureSet this value to 'true' to enable secure (HTTPS) access.
package main

import (
	"github.com/minio/minio-go"
	"log"
)

func main() {
	endpoint := "play.minio.io:9000"
	accessKeyID := "Q3AM3UQ867SPQQA43P2F"
	secretAccessKey := "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
	useSSL := true

	// Initialize minio client object.
	minioClient, err := minio.New(endpoint, accessKeyID, secretAccessKey, useSSL)
	if err != nil {
		log.Fatalln(err)
	}

	log.Printf("%#v\n", minioClient) // minioClient is now setup

Quick Start Example - File Uploader

This example program connects to an object storage server, creates a bucket and 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 (
	"github.com/minio/minio-go"
	"log"
)

func main() {
	endpoint := "play.minio.io:9000"
	accessKeyID := "Q3AM3UQ867SPQQA43P2F"
	secretAccessKey := "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
	useSSL := true

	// Initialize minio client object.
	minioClient, err := minio.New(endpoint, accessKeyID, secretAccessKey, useSSL)
	if err != nil {
		log.Fatalln(err)
	}

	// Make a new bucket called mymusic.
	bucketName := "mymusic"
	location := "us-east-1"

	err = minioClient.MakeBucket(bucketName, location)
	if err != nil {
		// Check to see if we already own this bucket (which happens if you run this twice)
		exists, err := minioClient.BucketExists(bucketName)
		if err == nil && exists {
			log.Printf("We already own %s\n", bucketName)
		} else {
			log.Fatalln(err)
		}
	}
	log.Printf("Successfully created %s\n", bucketName)

	// Upload the zip file
	objectName := "golden-oldies.zip"
	filePath := "/tmp/golden-oldies.zip"
	contentType := "application/zip"

	// Upload the zip file with FPutObject
	n, err := minioClient.FPutObject(bucketName, objectName, filePath, contentType)
	if err != nil {
		log.Fatalln(err)
	}

	log.Printf("Successfully uploaded %s of size %d\n", objectName, n)
}

Run FileUploader

go run file-uploader.go
2016/08/13 17:03:28 Successfully created mymusic 
2016/08/13 17:03:40 Successfully uploaded golden-oldies.zip of size 16253413

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: Encrypted Object Operations

API Reference : Presigned Operations

API Reference : Client custom settings

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 : Encrypted Object Operations

Full Examples : Presigned Operations

Explore Further

Contribute

Contributors Guide

Build Status Build status

# Packages

No description provided by the author

# Functions

ErrAPINotSupported - API not supported response The specified API call is not supported.
ErrEntityTooLarge - Input size is larger than supported maximum.
ErrEntityTooSmall - Input size is smaller than supported minimum.
ErrInvalidArgument - Invalid argument response.
ErrInvalidBucketName - Invalid bucket name response.
ErrInvalidObjectName - Invalid object name response.
ErrNoSuchBucketPolicy - No Such Bucket Policy response The specified bucket does not have a bucket policy.
ErrTransferAccelerationBucket - bucket name is invalid to be used with transfer acceleration.
ErrUnexpectedEOF - Unexpected end of file reached.
New - instantiate minio client, adds automatic verification of signature.
NewArn creates new ARN based on the given partition, service, region, account id and resource.
NewCore - Returns new initialized a Core client, this CoreClient should be only used under special conditions such as need to access lower primitives and being able to use them to write your own wrappers.
NewDestinationInfo - creates a compose-object/copy-source destination info object.
NewGetReqHeaders - initializes a new request headers for GET request.
NewHeadReqHeaders - initializes a new request headers for HEAD request.
NewNotificationConfig creates one notification config and sets the given ARN.
NewPostPolicy - Instantiate new post policy.
NewSourceInfo - create a compose-object/copy-object source info object.
NewSSEInfo - specifies (binary or un-encoded) encryption key and algorithm name.
NewV2 - instantiate minio client with Amazon S3 signature version '2' compatibility.
NewV4 - instantiate minio client with Amazon S3 signature version '4' compatibility.
NewWithCredentials - instantiate minio client with credentials provider for retrieving credentials from various credentials provider such as IAM, File, Env etc.
NewWithRegion - instantiate minio client, with region configured.
ToErrorResponse - Returns parsed ErrorResponse struct from body and http headers.

# Constants

DefaultRetryCap - Each retry attempt never waits no longer than this maximum time duration.
DefaultRetryUnit - default unit multiplicative per retry.
MaxJitter will randomize over the full exponential backoff time.
NoJitter disables the use of jitter for randomizing the exponential backoff time.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.
The role of all event types are described in : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations.

# Variables

ErrInvalidObjectPrefix - Invalid object prefix response is similar to object name response.
MaxRetry is the maximum number of retries before stopping.

# Structs

Arn - holds ARN information that will be sent to the web service, ARN desciption can be found in http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html.
BucketInfo container for bucket metadata.
BucketNotification - the struct that represents the whole XML to be sent to the web service.
Client implements Amazon S3 compatible methods.
CommonPrefix container for prefix response.
CompletePart sub container lists individual part numbers and their md5sum, part of completeMultipartUpload.
Core - Inherits Client and adds new methods to expose the low level S3 APIs.
DestinationInfo - type with information about the object to be created via server-side copy requests, using the Compose API.
ErrorResponse - Is the typed error returned by all API operations.
Filter - a tag in the notification xml structure which carries suffix/prefix filters.
FilterRule - child of S3Key, a tag in the notification xml which carries suffix/prefix filters.
LambdaConfig carries one single cloudfunction notification configuration.
ListBucketResult container for listObjects response.
ListBucketV2Result container for listObjects response version 2.
ListMultipartUploadsResult container for ListMultipartUploads response.
ListObjectPartsResult container for ListObjectParts response.
NotificationConfig - represents one single notification configuration such as topic, queue or lambda configuration.
NotificationEvent represents an Amazon an S3 bucket notification event.
NotificationInfo - represents the collection of notification events, additionally also reports errors if any while listening on bucket notifications.
Object represents an open object.
ObjectInfo container for object metadata.
ObjectMultipartInfo container for multipart object metadata.
ObjectPart container for particular part of an object.
PostPolicy - Provides strict static type conversion and validation for Amazon S3's POST policy JSON string.
QueueConfig carries one single queue notification configuration.
RemoveObjectError - container of Multi Delete S3 API error.
RequestHeaders - implement methods for setting special request headers for GET, HEAD object operations.
S3Key - child of Filter, a tag in the notification xml which carries suffix/prefix filters.
SourceInfo - represents a source object to be copied, using server-side copying APIs.
SSEInfo - represents Server-Side-Encryption parameters specified by a user.
TopicConfig carries one single topic notification configuration.

# Type aliases

NotificationEventType is a S3 notification event associated to the bucket notification configuration.