Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

minio-go

> 开发工具
Open source

MinIO Go client SDK for S3 compatible object storage

3.0K stars0 likes3 views
WebsiteGitHub

About

MinIO Go client SDK for S3 compatible object storage

MinIO Go Client SDK for Amazon S3 Compatible Cloud Storage

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

This Quickstart Guide covers how to install the MinIO client SDK, connect to MinIO, and create a sample file uploader. For a complete list of APIs and examples, see the godoc documentation or Go Client API Reference.

These examples presume a working Go development environment and the MinIO mc command line tool.

Download from Github

From your project directory:

bash
go get github.com/minio/minio-go/v7

Initialize a MinIO Client Object

The MinIO client requires the following parameters to connect to an Amazon S3 compatible object storage:

Parameter Description
endpoint URL to object storage service.
_minio.Options_ All the options such as credentials, custom transport etc.
go
package main

import (
	"log"

	"github.com/minio/minio-go/v7"
	"github.com/minio/minio-go/v7/pkg/credentials"
)

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

	// Initialize minio client object.
	minioClient, err := minio.New(endpoint, &minio.Options{
		Creds:  credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),
		Secure: useSSL,
	})
	if err != nil {
		log.Fatalln(err)
	}

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

Example - File Uploader

This sample code connects to an object storage server, creates a bucket, and uploads a file to the bucket. It uses the MinIO play server, a public MinIO cluster located at https://play.min.io.

The play server runs the latest stable version of MinIO and may be used for testing and development. The access credentials shown in this example are open to the public and all data uploaded to play should be considered public and non-protected.

FileUploader.go

This example does the following:

  • Connects to the MinIO play server using the provided credentials.
  • Creates a bucket named testbucket.
  • Uploads a file named testdata from /tmp.
  • Verifies the file was created using mc ls.
…

1. Create a test file containing data:

You can do this with dd on Linux or macOS systems:

bash
dd if=/dev/urandom of=/tmp/testdata bs=2048 count=10

or fsutil on Windows:

bash
fsutil file createnew "C:\Users\<username>\Desktop\sample.txt" 20480

2. Run FileUploader with the following commands:

bash
go mod init example/FileUploader
go get github.com/minio/minio-go/v7
go get github.com/minio/minio-go/v7/pkg/credentials
go run FileUploader.go

The output resembles the following:

bash
2023/11/01 14:27:55 Successfully created testbucket
2023/11/01 14:27:55 Successfully uploaded testdata of size 20480

3. Verify the Uploaded File With mc ls:

bash
mc ls play/testbucket
[2023-11-01 14:27:55 UTC]  20KiB STANDARD TestDataFile

API Reference

The full API Reference is available here.

  • Complete API Reference

API Reference : Bucket Operations

  • MakeBucket
  • ListBuckets
  • BucketExists
  • RemoveBucket
  • ListObjects
  • ListIncompleteUploads

API Reference : Bucket policy Operations

  • SetBucketPolicy
  • GetBucketPolicy

API Reference : Bucket notification Operations

  • SetBucketNotification
  • GetBucketNotification
  • RemoveAllBucketNotification
  • ListenBucketNotification (MinIO Extension)
  • ListenNotification (MinIO Extension)

API Reference : File Object Operations

  • FPutObject
  • FGetObject

API Reference : Object Operations

  • GetObject
  • PutObject
  • PutObjectStreaming
  • StatObject
  • CopyObject
  • RemoveObject
  • RemoveObjects
  • RemoveIncompleteUpload
  • SelectObjectContent
  • PutObjectAnnotation
  • GetObjectAnnotation
  • ListObjectAnnotations
  • RemoveObjectAnnotation

API Reference : Presigned Operations

  • PresignedGetObject
  • PresignedPutObject
  • PresignedHeadObject
  • PresignedPostPolicy

API Reference : Client custom settings

  • SetAppInfo
  • TraceOn
  • TraceOff

Full Examples

Full Examples : Bucket Operations

  • makebucket.go
  • listbuckets.go
  • bucketexists.go
  • removebucket.go
  • listobjects.go
  • listobjectsV2.go
  • listincompleteuploads.go

Full Examples : Bucket policy Operations

  • setbucketpolicy.go
  • getbucketpolicy.go
  • listbucketpolicies.go

Full Examples : Bucket lifecycle Operations

  • setbucketlifecycle.go
  • getbucketlifecycle.go

Full Examples : Bucket encryption Operations

  • setbucketencryption.go
  • getbucketencryption.go
  • removebucketencryption.go

Full Examples : Bucket replication Operations

  • setbucketreplication.go
  • getbucketreplication.go
  • removebucketreplication.go

Full Examples : Bucket notification Operations

  • setbucketnotification.go
  • getbucketnotification.go
  • removeallbucketnotification.go
  • listenbucketnotification.go (MinIO Extension)
  • listennotification.go (MinIO Extension)

Full Examples : File Object Operations

  • fputobject.go
  • fgetobject.go

Full Examples : Object Operations

  • putobject.go
  • getobject.go
  • statobject.go
  • copyobject.go
  • removeobject.go
  • removeincompleteupload.go
  • removeobjects.go
  • putobjectannotation.go
  • getobjectannotation.go
  • listobjectannotations.go
  • [removeobjectannotation.go](https://github.com/minio/minio-go/blob/master/examples/s3/removeobjec

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Goaws-signatureclient-sdkcloudfileuploader

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具