Azure Blob
Azure Blob storage는 클라우드를 위한 Microsoft의 객체 스토리지 솔루션입니다.
참고: 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) Conn() azblob.Client
Installation
Azure blob storage 드라이버는 모듈 지원이 되는 Go 최신 2개 버전에서 테스트되었습니다. 아직 초기화하지 않았다면 먼저 초기화해야 합니다:
go mod init github.com/<user>/<repo>
그리고 azure blob 구현을 설치합니다:
go get github.com/gofiber/storage/azureblob/v2
Examples
storage 패키지를 가져옵니다.
import "github.com/gofiber/storage/azureblob/v2"
다음과 같은 방법으로 storage를 생성할 수 있습니다:
// 기본 config 초기화
store := azureblob.New()
// 커스텀 config 초기화
store := azureblob.New(azureblob.Config{
Account: "test",
Container: "test",
Credentials: Credentials{
Account: "test",
Key: "YXp1cml0ZWtleQo=",
},
})
Config
type Config struct {
// Storage 계정명.
Account string
// 컨테이너명.
Container string
// Storage endpoint.
// 선택사항. 기본값: "https://STORAGEACCOUNTNAME.blob.core.windows.net"
Endpoint string
// 요청 타임아웃.
// 선택사항. 기본값은 0(타임아웃 없음)
RequestTimeout time.Duration
// Reset은 기존 컨테이너의 모든 키를 삭제합니다.
// 선택사항. 기본값은 false
Reset bool
// Credentials는 AWS access key와 AWS secret access key를 오버라이드합니다. 비추천.
// 선택사항. 기본값은 Credentials{}
Credentials Credentials
// 실패한 재시도 가능한 요청의 최대 시도 횟수.
// 선택사항. 기본값은 3
MaxAttempts int
}
Default Config
var ConfigDefault = Config{
Account: "",
Container: "",
Endpoint: "",
RequestTimeout: 0,
Reset: false,
MaxAttempts: 3,
}
Last updated