Skip to content
Go Makefile
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Add ObjectTagging Support (#1206) Jan 11, 2020
examples Add ObjectTagging Support (#1206) Jan 11, 2020
pkg Remove empty X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id request head… Jan 17, 2020
testcerts Increase default multipart size to 128MiB (#1112) May 28, 2019
.gitignore Fix docs and add a validator tool for our api docs (#850) Oct 27, 2017
.travis.yml Core: Expose Response header in GetObject (#1166) Sep 29, 2019
CONTRIBUTING.md http/Client: Add a sensible 30sec timeout to wait for response. Feb 14, 2016
LICENSE Object storage library - first commit May 2, 2015
MAINTAINERS.md Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
Makefile Support ListObjectsWithMetadata API (#1189) Nov 21, 2019
NOTICE Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
README.md Fix documentation on minio-go download (#1155) Sep 3, 2019
README_zh_CN.md Fix broken link to go install docs (#1149) Aug 15, 2019
api-compose-object.go Add ObjectTagging Support (#1206) Jan 11, 2020
api-compose-object_test.go Add ObjectTagging Support (#1206) Jan 11, 2020
api-datatypes.go Add grant information in GetObjectACL (#1190) Dec 4, 2019
api-error-response.go detect snowball server automatically using server header (#1213) Jan 11, 2020
api-error-response_test.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
api-get-lifecycle.go Fix go module imports properly to honor semantic versioning (#1111) May 24, 2019
api-get-object-acl-context.go Add grant information in GetObjectACL (#1190) Dec 4, 2019
api-get-object-acl.go Add owner information in GetObjectACL and add Context (#1182) Nov 26, 2019
api-get-object-context.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
api-get-object-file.go Core: Expose Response header in GetObject (#1166) Sep 29, 2019
api-get-object.go detect snowball server automatically using server header (#1213) Jan 11, 2020
api-get-options.go Fix go module imports properly to honor semantic versioning (#1111) May 24, 2019
api-get-policy.go Fix go module imports properly to honor semantic versioning (#1111) May 24, 2019
api-list.go detect snowball server automatically using server header (#1213) Jan 11, 2020
api-notification.go Remove ListenBucketNotificationV2 (#1204) Dec 13, 2019
api-object-lock.go Add object retention support (#1187) Nov 20, 2019
api-object-retention.go Add object retention support (#1187) Nov 20, 2019
api-object-tagging.go Add ObjectTagging Support (#1206) Jan 11, 2020
api-presigned.go Fix go module imports properly to honor semantic versioning (#1111) May 24, 2019
api-put-bucket.go Add Bucket APIs with context support (#1192) Dec 5, 2019
api-put-object-common.go fix: allow configurable part size with -1 content-length (#1215) Jan 16, 2020
api-put-object-context.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
api-put-object-copy.go Add ObjectTagging Support (#1206) Jan 11, 2020
api-put-object-file-context.go Fix go module imports properly to honor semantic versioning (#1111) May 24, 2019
api-put-object-file.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
api-put-object-multipart.go Trim all etags with single function (#1197) Dec 9, 2019
api-put-object-streaming.go Trim all etags with single function (#1197) Dec 9, 2019
api-put-object.go Add ObjectTagging Support (#1206) Jan 11, 2020
api-put-object_test.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
api-remove.go Add object retention support (#1187) Nov 20, 2019
api-s3-datatypes.go Add ObjectTagging Support (#1206) Jan 11, 2020
api-select.go Export Select Result Parser (#1170) Oct 1, 2019
api-stat.go Add ObjectTagging Support (#1206) Jan 11, 2020
api.go Add ObjectTagging Support (#1206) Jan 11, 2020
api_unit_test.go fix: allow configurable part size with -1 content-length (#1215) Jan 16, 2020
appveyor.yml Fix go module imports properly to honor semantic versioning (#1111) May 24, 2019
bucket-cache.go detect snowball server automatically using server header (#1213) Jan 11, 2020
bucket-cache_test.go Data race: Use a copy instead of a pointer to url.URL (#1126) Jun 21, 2019
bucket-notification.go Fix go module imports properly to honor semantic versioning (#1111) May 24, 2019
constants.go Add ObjectTagging Support (#1206) Jan 11, 2020
core.go Add Bucket APIs with context support (#1192) Dec 5, 2019
core_test.go Core: Expose Response header in GetObject (#1166) Sep 29, 2019
functional_tests.go Add Bucket APIs with context support (#1192) Dec 5, 2019
get-options_test.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
go.mod Fix listObjects hang when listing special characters (#1165) Sep 23, 2019
go.sum list: Fix encoding in listing results (#1171) Oct 4, 2019
hook-reader.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
post-policy.go Add funcion to set policy parameter (#1200) Jan 2, 2020
retry-continous.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
retry.go Retry for all network errors regardless (#1198) Dec 9, 2019
s3-endpoints.go support new ap-east-1 region (#1105) May 11, 2019
s3-error.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
staticcheck.conf Fix go module imports properly to honor semantic versioning (#1111) May 24, 2019
test-utils_test.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
transport.go Replace Minio with MinIO and minio.io with min.io (#1096) Apr 7, 2019
utils.go Trim all etags with single function (#1197) Dec 9, 2019
utils_test.go Fix go module imports properly to honor semantic versioning (#1111) May 24, 2019

README.md

MinIO Go Client SDK for Amazon S3 Compatible Cloud Storage Slack Sourcegraph Apache V2 License

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

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

GO111MODULE=on go get github.com/minio/minio-go/v6

Initialize MinIO Client

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

Parameter Description
endpoint URL to object storage service.
accessKeyID Access key is the 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 (
	"github.com/minio/minio-go/v6"
	"log"
)

func main() {
	endpoint := "play.min.io"
	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.min.io 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/v6"
	"log"
)

func main() {
	endpoint := "play.min.io"
	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, errBucketExists := minioClient.BucketExists(bucketName)
		if errBucketExists == nil && exists {
			log.Printf("We already own %s\n", bucketName)
		} else {
			log.Fatalln(err)
		}
	} else {
		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, minio.PutObjectOptions{ContentType: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 : Presigned Operations

API Reference : Client custom settings

Full Examples

Full Examples : Bucket Operations

Full Examples : Bucket policy Operations

Full Examples : Bucket lifecycle 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

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE and NOTICE for more information.

You can’t perform that action at this time.