MinIO Go Client API使用

1. 前言

本文我们将学习MinIO Go Client API使用,MinIO安装参考。对于完整的API以及示例,请参考Go Client API Reference

2. Go Client

2.1 初始化MinIO Client

MinIO client需要以下4个参数来连接与Amazon S3兼容的对象存储

endpoint :对象存储服务的URL

accessKeyID:Access key是唯一标识你的账户的用户ID,默认minioadmin

secretAccessKey:Secret key是你账户的密码,默认minioadmin

secure:true代表使用HTTPS

2.2 样例

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 setup
}

 

 

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页