Go Fiber 한글 공식 문서
  • 🙇‍♀️안녕하세요
  • 🏠Home
    • 👋Welcome
    • 📁API
      • 📦Fiber
      • 🚀App
      • 🧠Ctx
      • 📋Constants
      • 🌎Client
      • 📃Log
      • 🧬Middleware
        • Adaptor
        • BasicAuth
        • Cache
        • Compress
        • CORS
        • CSRF
        • EarlyData
        • Encrypt Cookie
        • EnvVar
        • ETag
        • ExpVar
        • Favicon
        • FileSystem
        • Health Check
        • Helmet
        • Idempotency
        • Keyauth
        • Limiter
        • Logger
        • Monitor
        • Pprof
        • Proxy
        • Recover
        • Redirect
        • RequestID
        • Rewrite
        • Session
        • Skip
        • Timeout
    • 📁Guide
      • 🔌Routing
      • 🎭Grouping
      • 📝Templates
      • 🐛Error Handling
      • 🔎Validation
      • 🎣Hooks
      • ⚡Make Fiber Faster
    • 📁Extra
      • 🤔FAQ
      • 📊Benchmarks
  • 🧩Extra
    • 🧬Contrip
      • 👋Welcome
      • Casbin
      • Fgprof
      • Fiberi18n
      • Fibernewrelic
      • Fibersentry
      • Fiberzap
      • Fiberzerolog
      • JWT
      • LoadShed
      • Opafiber
      • Otelfiber
        • Example
      • Paseto
      • README
      • Swagger
      • Websocket
    • 📦Storage
      • 👋Welcome
      • ArangoDB
      • Azure Blob
      • Badger
      • Bbolt
      • Coherence
      • Couchbase
      • DynamoDB
      • Etcd
      • Memcache
      • Memory
      • Minio
      • MongoDB
      • MSSQL
      • MySQL
      • Nats
      • Pebble
      • Postgres
      • Redis
      • Ristretto
      • Rueidis
      • S3
      • ScyllaDb
      • SQLite3
    • 📃Template
      • 👋Welcome
      • Ace
      • Amber
      • Django
      • Handlebars
      • HTML
        • Golang Templates Cheatsheet
      • Jet
      • Mustache
      • Pug
      • Slim
Powered by GitBook
On this page
  • Table of Contents
  • Signatures
  • Installation
  • Examples
  • Config
  • Default Config
  1. Extra
  2. Storage

Minio

PreviousMemoryNextMongoDB

Last updated 1 year ago


를 사용하는 Minio 스토리지 드라이버입니다.

참고: Go 1.19 이상이 필요합니다

Table of Contents

  • Signatures

  • Installation

  • Examples

  • Config

  • Default Config

Signatures

func New(config ...Config) Storage
func (s *Storage) Get(key string) ([]byte, error)  
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
func (s *Storage) Delete(key string) error
func (s *Storage) Reset() error
func (s *Storage) Close() error
func (s *Storage) CheckBucket() error
func (s *Storage) CreateBucket() error
func (s *Storage) RemoveBucket() error
func (s *Storage) Conn() *minio.Client

Installation

Minio 구현을 설치합니다:

go get github.com/gofiber/storage/minio

그리고 Docker에서 minio를 실행합니다.

docker run -d --restart always -p 9000:9000 -p 9001:9001 --name storage-minio --volume=minio:/var/lib/minio -e MINIO_ROOT_USER='minio-user' -e MINIO_ROOT_PASSWORD='minio-password' minio/minio server --console-address ":9001" /var/lib/minio  

Examples

storage 패키지를 import 합니다.

import "github.com/gofiber/storage/minio"

다음과 같은 방법으로 스토리지를 생성할 수 있습니다:

// 기본 config 초기화
store := minio.New()

// 사용자 정의 config 초기화 
store := minio.New(minio.Config{
	Bucket:   "fiber-bucket",
	Endpoint: "localhost:9000",
	Credentials: Credentials{
		AccessKeyID:     "minio-user",  
		SecretAccessKey: "minio-password",
	},
})

Config

// Config 스토리지에 대한 설정을 정의합니다.
type Config struct {
	// Bucket
	// 기본값 fiber-bucket
	Bucket string

	// Endpoint는 호스트 이름 또는 IP 주소입니다.
	Endpoint string

	// Region 캐시를 덮어쓰기 위해 이 값을 설정합니다.
	// 선택 사항
	Region string
	
	// Token x-amz-security-token(AWS S3 전용)을 제공하려면 이 값을 설정하세요.
	// 선택 사항, 기본값은 false입니다.
	Token string

	// Secure true로 설정하면 http 대신 https가 사용됩니다.
	// 기본값은 false입니다.
	Secure bool

	// Reset 기존 Bucket에 있는 기존 키를 모두 지웁니다.
	// 선택 사항. 기본값은 false입니다.
	Reset bool
	
	// Credentials Minio 액세스 키와 Minio 비밀 키.
	// 정의되어야 합니다.
	Credentials Credentials
	
	// GetObjectOptions 암호화, If-Match와 같은 추가 옵션을 지정하는 GET 요청 옵션
	GetObjectOptions minio.GetObjectOptions
	
	// PutObjectOptions
	// 사용자가 멀티파트 업로드 작업을 위한 선택적 사용자 정의 메타데이터, 콘텐츠 헤더, 암호화 키 및 스레드 수를 설정할 수 있습니다.
	PutObjectOptions minio.PutObjectOptions
	
	// ListObjectsOptions 객체를 나열하는 옵션
	ListObjectsOptions minio.ListObjectsOptions
	
	// RemoveObjectOptions 사용자가 옵션을 설정할 수 있습니다.
	RemoveObjectOptions minio.RemoveObjectOptions  
}

Default Config

기본 설정에는 필수이며 반드시 덮어써야 하는 Bucket, Region 및 Endpoint가 없습니다:

// ConfigDefault는 기본 설정입니다.
var ConfigDefault = Config{
	Bucket:              "fiber-bucket",
	Endpoint:            "",
	Region:              "",   
	Token:               "",
	Secure:              false,
	Reset:               false,
	Credentials:         Credentials{},
	GetObjectOptions:    minio.GetObjectOptions{},
	PutObjectOptions:    minio.PutObjectOptions{},
	ListObjectsOptions:  minio.ListObjectsOptions{},
	RemoveObjectOptions: minio.RemoveObjectOptions{},
}
type Credentials struct {
	AccessKeyID     string 
	SecretAccessKey string
}
🧩
📦
minio/minio-go