storage

package module
v0.0.0-...-0dabf99 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 32 Imported by: 2

README

Storage

A GORM-style storage wrapper with unified API for different cloud storage backends

Documentation

Overview

Copyright 2025 LiveKit, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AliOSSConfig

type AliOSSConfig struct {
	AccessKey string `yaml:"access_key"`
	Secret    string `yaml:"secret"`
	Endpoint  string `yaml:"endpoint"`
	Bucket    string `yaml:"bucket"`
}

type AzureConfig

type AzureConfig struct {
	AccountName     string                 `yaml:"account_name"` // (env AZURE_STORAGE_ACCOUNT)
	AccountKey      string                 `yaml:"account_key"`  // (env AZURE_STORAGE_KEY)
	ContainerName   string                 `yaml:"container_name"`
	TokenCredential azblob.TokenCredential `yaml:"-"` // required for presigned url generation
}

type GCPConfig

type GCPConfig struct {
	CredentialsJSON string       `yaml:"credentials_json"` // (env GOOGLE_APPLICATION_CREDENTIALS)
	Bucket          string       `yaml:"bucket"`
	ProxyConfig     *ProxyConfig `yaml:"proxy_config"`
}

type ProxyConfig

type ProxyConfig struct {
	Url      string `yaml:"url"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type S3Config

type S3Config struct {
	AccessKey            string       `yaml:"access_key"`
	Secret               string       `yaml:"secret"`
	SessionToken         string       `yaml:"session_token"`
	AssumeRoleArn        string       `yaml:"assume_role_arn"`         // ARN of the role to assume for file upload. Egress will make an AssumeRole API call using the provided access_key and secret to assume that role
	AssumeRoleExternalId string       `yaml:"assume_role_external_id"` // ExternalID to use when assuming role for upload
	Region               string       `yaml:"region"`
	Endpoint             string       `yaml:"endpoint"`
	Bucket               string       `yaml:"bucket"`
	ForcePathStyle       bool         `yaml:"force_path_style"`
	ProxyConfig          *ProxyConfig `yaml:"proxy_config"`

	MaxRetries    int           `yaml:"max_retries"`
	MaxRetryDelay time.Duration `yaml:"max_retry_delay"`
	MinRetryDelay time.Duration `yaml:"min_retry_delay"`

	Metadata           map[string]string `yaml:"metadata"`
	Tagging            string            `yaml:"tagging"`
	ContentDisposition string            `yaml:"content_disposition"`
}

type S3Logger

type S3Logger struct {
	// contains filtered or unexported fields
}

S3Logger only logs aws messages on upload failure

func NewS3Logger

func NewS3Logger() *S3Logger

func (*S3Logger) Logf

func (l *S3Logger) Logf(classification logging.Classification, format string, v ...interface{})

func (*S3Logger) WriteLogs

func (l *S3Logger) WriteLogs()

type Storage

type Storage interface {
	UploadData(data []byte, storagePath, contentType string) (location string, size int64, err error)
	UploadFile(filepath, storagePath, contentType string) (location string, size int64, err error)

	DownloadData(storagePath string) (data []byte, err error)
	DownloadFile(filepath, storagePath string) (size int64, err error)

	GeneratePresignedUrl(storagePath string, expiration time.Duration) (url string, err error)

	Delete(storagePath string) error
}

func NewAliOSS

func NewAliOSS(conf *AliOSSConfig) (Storage, error)

func NewAzure

func NewAzure(conf *AzureConfig) (Storage, error)

func NewGCP

func NewGCP(conf *GCPConfig) (Storage, error)

func NewLocal

func NewLocal() Storage

func NewS3

func NewS3(conf *S3Config) (Storage, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL