0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-03 00:38:11 +01:00
gitea/vendor/github.com/minio/minio-go/v7
6543 d1353e1f7c
Vendor Update (#14496)
* update code.gitea.io/sdk/gitea v0.13.1 -> v0.13.2

* update github.com/go-swagger/go-swagger v0.25.0 -> v0.26.0

* update github.com/google/uuid v1.1.2 -> v1.2.0

* update github.com/klauspost/compress v1.11.3 -> v1.11.7

* update github.com/lib/pq 083382b7e6fc -> v1.9.0

* update github.com/markbates/goth v1.65.0 -> v1.66.1

* update github.com/mattn/go-sqlite3 v1.14.4 -> v1.14.6

* update github.com/mgechev/revive 246eac737dc7 -> v1.0.3

* update github.com/minio/minio-go/v7 v7.0.6 -> v7.0.7

* update github.com/niklasfasching/go-org v1.3.2 -> v1.4.0

* update github.com/olivere/elastic/v7 v7.0.21 -> v7.0.22

* update github.com/pquerna/otp v1.2.0 -> v1.3.0

* update github.com/xanzy/go-gitlab v0.39.0 -> v0.42.0

* update github.com/yuin/goldmark v1.2.1 -> v1.3.1
2021-01-28 17:56:38 +01:00
..
pkg Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
.gitignore
.golangci.yml
api-bucket-encryption.go
api-bucket-lifecycle.go
api-bucket-notification.go
api-bucket-policy.go
api-bucket-replication.go
api-bucket-tagging.go
api-bucket-versioning.go [Vendor] Update Batch 2020-11 (#13746) 2020-11-29 15:54:08 -05:00
api-compose-object.go Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
api-datatypes.go
api-error-response.go Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
api-get-object-acl.go
api-get-object-file.go
api-get-object.go
api-get-options.go Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
api-list.go
api-object-legal-hold.go
api-object-lock.go
api-object-retention.go
api-object-tagging.go
api-presigned.go
api-put-bucket.go
api-put-object-common.go
api-put-object-copy.go
api-put-object-file-context.go
api-put-object-multipart.go
api-put-object-streaming.go [Vendor] Update Batch 2020-11 (#13746) 2020-11-29 15:54:08 -05:00
api-put-object.go Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
api-remove.go Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
api-s3-datatypes.go [Vendor] Update Batch 2020-11 (#13746) 2020-11-29 15:54:08 -05:00
api-select.go
api-stat.go [Vendor] Update Batch 2020-11 (#13746) 2020-11-29 15:54:08 -05:00
api.go Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
bucket-cache.go [Vendor] Update Batch 2020-11 (#13746) 2020-11-29 15:54:08 -05:00
CNAME
code_of_conduct.md
constants.go Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
CONTRIBUTING.md
core.go [Vendor] Update Batch 2020-11 (#13746) 2020-11-29 15:54:08 -05:00
go.mod Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
go.sum Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
hook-reader.go
LICENSE
MAINTAINERS.md
Makefile [Vendor] Update Batch 2020-11 (#13746) 2020-11-29 15:54:08 -05:00
NOTICE
post-policy.go Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
README.md Vendor Update (#14496) 2021-01-28 17:56:38 +01:00
README_zh_CN.md [Vendor] Update Batch 2020-11 (#13746) 2020-11-29 15:54:08 -05:00
retry-continous.go
retry.go [Vendor] Update Batch 2020-11 (#13746) 2020-11-29 15:54:08 -05:00
s3-endpoints.go
s3-error.go
staticcheck.conf
transport.go
utils.go [Vendor] Update Batch 2020-11 (#13746) 2020-11-29 15:54:08 -05:00

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/v7

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.
minio.Options All the options such as credentials, custom transport etc.
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
}

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 (
	"context"
	"log"

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

func main() {
	ctx := context.Background()
	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)
	}

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

	err = minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{Region: location})
	if err != nil {
		// Check to see if we already own this bucket (which happens if you run this twice)
		exists, errBucketExists := minioClient.BucketExists(ctx, 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(ctx, 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

export GO111MODULE=on
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 encryption Operations

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

License

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