Go Makefile
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs Add support for bucket lifecycle policies (#1004) Jul 16, 2018
examples Add new method GetObjectACL() (#1011) Jul 27, 2018
pkg Add check for env var (#1008) Jul 15, 2018
.gitignore Fix docs and add a validator tool for our api docs (#850) Oct 27, 2017
.travis.yml Add license section for brevity. (#871) Nov 15, 2017
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 Move master branch to upcoming release version 4.0.0 (#817) Sep 21, 2017
Makefile Add SSE-C tests for multipart, copy, get range operations (#941) Mar 7, 2018
NOTICE Add license section for brevity. (#871) Nov 15, 2017
README.md Add support for bucket lifecycle policies (#1004) Jul 16, 2018
README_zh_CN.md Update get/setBucketPolicy methods to use files instead of pkg/policy ( Apr 9, 2018
api-compose-object.go Disable ETag check when copying object < 5 Gb (#1014) Aug 6, 2018
api-compose-object_test.go New way to update ObjectACL or Header or Meta data (#1010) Jul 19, 2018
api-datatypes.go Ignore Metadata field in xml encode/decode (#890) Dec 4, 2017
api-error-response.go Add license section for brevity. (#871) Nov 15, 2017
api-error-response_test.go Add license section for brevity. (#871) Nov 15, 2017
api-get-lifecycle.go Add support for bucket lifecycle policies (#1004) Jul 16, 2018
api-get-object-acl.go Add new method GetObjectACL() (#1011) Jul 27, 2018
api-get-object-context.go Add license section for brevity. (#871) Nov 15, 2017
api-get-object-file.go Add SSE and refactor encryption API (#942) Mar 12, 2018
api-get-object.go Add SSE and refactor encryption API (#942) Mar 12, 2018
api-get-options.go avoid sending SSE-S3 header during GET requests. (#965) Apr 5, 2018
api-get-policy.go Update get/setBucketPolicy methods to use files instead of pkg/policy ( Apr 9, 2018
api-list.go RemoveIncompleteUpload to remove all incomplete uploads (#994) Jun 19, 2018
api-notification.go Removing conditional check for notificationInfoCh in api-notication (#… Mar 5, 2018
api-presigned.go Sign V2: Fix signature calculation in virtual host style (#921) Feb 16, 2018
api-put-bucket.go Add support for bucket lifecycle policies (#1004) Jul 16, 2018
api-put-object-common.go Add license section for brevity. (#871) Nov 15, 2017
api-put-object-context.go Add SSE and refactor encryption API (#942) Mar 12, 2018
api-put-object-copy.go Add progress bar support for ComposeObject (#969) Apr 24, 2018
api-put-object-file-context.go Add license section for brevity. (#871) Nov 15, 2017
api-put-object-file.go Add license section for brevity. (#871) Nov 15, 2017
api-put-object-multipart.go Fix stream SSE uploads with S3 encrypt type (#960) Apr 2, 2018
api-put-object-streaming.go Add SSE and refactor encryption API (#942) Mar 12, 2018
api-put-object.go Change import httplex to httpguts. (#981) May 7, 2018
api-put-object_test.go Add support for Content-Language metadata header (#928) Feb 23, 2018
api-remove.go RemoveIncompleteUpload to remove all incomplete uploads (#994) Jun 19, 2018
api-s3-datatypes.go Add license section for brevity. (#871) Nov 15, 2017
api-stat.go Avoid returning security related header when stating an object (#975) Apr 26, 2018
api.go Remove work-around for httputil.Dump (#1017) Aug 16, 2018
api_unit_test.go Sign V2: Fix signature calculation in virtual host style (#921) Feb 16, 2018
appveyor.yml Add SSE and refactor encryption API (#942) Mar 12, 2018
bucket-cache.go Sign V2: Fix signature calculation in virtual host style (#921) Feb 16, 2018
bucket-cache_test.go Sign V2: Fix signature calculation in virtual host style (#921) Feb 16, 2018
bucket-notification.go Fix check for duplicate notification configuration entries (#917) Feb 22, 2018
constants.go api: maximize ComposeObject to use more parts than part size (#968) Apr 24, 2018
core.go Added support for the start-after parameter when performing a List Ob… Jun 13, 2018
core_test.go Update get/setBucketPolicy methods to use files instead of pkg/policy ( Apr 9, 2018
functional_tests.go Add new method GetObjectACL() (#1011) Jul 27, 2018
get-options_test.go Add license section for brevity. (#871) Nov 15, 2017
hook-reader.go Add license section for brevity. (#871) Nov 15, 2017
post-policy.go Add license section for brevity. (#871) Nov 15, 2017
retry-continous.go Add license section for brevity. (#871) Nov 15, 2017
retry.go Fix retrying retryable http requests errors (#1016) Aug 7, 2018
s3-endpoints.go Add new regions for Paris and China west. (#905) Jan 8, 2018
s3-error.go Add license section for brevity. (#871) Nov 15, 2017
test-utils_test.go Add license section for brevity. (#871) Nov 15, 2017
transport.go allow OS to cleanup sockets in TIME_WAIT (#925) Feb 21, 2018
utils.go Add "Expires" to standard header (#1012) Jul 23, 2018
utils_test.go Add SSE and refactor encryption API (#942) Mar 12, 2018

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

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.

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"
	"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, 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.