oss

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

README

OSS - Object Storage Service

English | 简体中文

A unified object storage abstraction layer supporting multiple cloud storage providers and local filesystem.

Features

  • Multi-Cloud Support: AWS S3, Azure Blob, Aliyun OSS, Tencent COS, Google Cloud Storage, MinIO, Qiniu Kodo, Synology NAS, and Local Filesystem
  • Unified Interface: All storage providers implement the same consistent API
  • Auto-Registration: Drivers are automatically registered via init() functions
  • Official SDKs: Leverages official SDKs from each cloud provider
  • Local Storage: Built-in support for local filesystem storage
  • Lightweight: Standalone module with minimal dependencies

Installation

go get github.com/ncobase/ncore/oss

Quick Start

package main

import (
    "fmt"
    "strings"

    "github.com/ncobase/ncore/oss"
)

func main() {
    // Create storage configuration
    cfg := &oss.Config{
        Provider: "minio",
        ID:       "minioadmin",
        Secret:   "minioadmin",
        Bucket:   "mybucket",
        Endpoint: "http://localhost:9000",
    }

    // Create storage instance
    storage, err := oss.NewStorage(cfg)
    if err != nil {
        panic(err)
    }

    // Upload file
    content := strings.NewReader("Hello, World!")
    obj, err := storage.Put("test.txt", content)
    if err != nil {
        panic(err)
    }
    fmt.Printf("Uploaded: %s\n", obj.Path)

    // Check if file exists
    exists, err := storage.Exists("test.txt")
    if err != nil {
        panic(err)
    }
    fmt.Printf("Exists: %v\n", exists)

    // Get file metadata
    stat, err := storage.Stat("test.txt")
    if err != nil {
        panic(err)
    }
    fmt.Printf("Size: %d bytes\n", stat.Size)

    // Get file
    file, err := storage.Get("test.txt")
    if err != nil {
        panic(err)
    }
    defer file.Close()

    // Get presigned download URL
    url, err := storage.GetURL("test.txt")
    if err != nil {
        panic(err)
    }
    fmt.Printf("URL: %s\n", url)

    // Delete file
    if err := storage.Delete("test.txt"); err != nil {
        panic(err)
    }
}

Supported Providers

Provider Provider Value Required Config
AWS S3 s3 ID, Secret, Bucket, Region
Azure Blob azure ID (account), Secret (key), Bucket
Aliyun OSS aliyun ID, Secret, Bucket, Region
Tencent COS tencent ID, Secret, Bucket, Region, AppID
Google Cloud Storage gcs Bucket, ServiceAccountJSON or Secret
MinIO minio ID, Secret, Bucket, Endpoint
Qiniu Kodo qiniu ID, Secret, Bucket, Region, Endpoint
Synology NAS synology ID, Secret, Bucket, Endpoint
Local Filesystem filesystem Bucket (path, defaults to ./uploads)

Configuration Examples

AWS S3
cfg := &oss.Config{
    Provider: "s3",
    ID:       "your-access-key-id",
    Secret:   "your-secret-access-key",
    Bucket:   "my-bucket",
    Region:   "us-east-1",
}
MinIO
cfg := &oss.Config{
    Provider: "minio",
    ID:       "minioadmin",
    Secret:   "minioadmin",
    Bucket:   "mybucket",
    Endpoint: "http://localhost:9000",
}
Aliyun OSS
cfg := &oss.Config{
    Provider: "aliyun",
    ID:       "your-access-key-id",
    Secret:   "your-access-key-secret",
    Bucket:   "my-bucket",
    Region:   "cn-hangzhou",
}
Tencent COS
cfg := &oss.Config{
    Provider: "tencent",
    ID:       "your-secret-id",
    Secret:   "your-secret-key",
    Bucket:   "my-bucket",
    Region:   "ap-guangzhou",
    AppID:    "1234567890",
}
Azure Blob Storage
cfg := &oss.Config{
    Provider: "azure",
    ID:       "your-account-name",
    Secret:   "your-account-key",
    Bucket:   "my-container",
}
Google Cloud Storage
cfg := &oss.Config{
    Provider:           "gcs",
    Bucket:             "my-bucket",
    ServiceAccountJSON: "/path/to/service-account.json",
}
Qiniu Kodo
cfg := &oss.Config{
    Provider: "qiniu",
    ID:       "your-access-key",
    Secret:   "your-secret-key",
    Bucket:   "my-bucket",
    Region:   "cn-east-1",
    Endpoint: "https://my-bucket.qiniudn.com",
}
Synology NAS
cfg := &oss.Config{
    Provider: "synology",
    ID:       "your-access-key",
    Secret:   "your-secret-key",
    Bucket:   "my-bucket",
    Endpoint: "https://nas.example.com:5001",
}
Local Filesystem
cfg := &oss.Config{
    Provider: "filesystem",
    Bucket:   "/var/data/storage",
}

API Reference

Interface
type Interface interface {
    // Get downloads a file to a temporary file and returns the file handle.
    // Caller is responsible for closing the file and removing it when done.
    Get(path string) (*os.File, error)

    // GetStream returns a readable stream for streaming large file downloads.
    // Caller is responsible for closing the reader when done.
    GetStream(path string) (io.ReadCloser, error)

    // Put uploads a file from the given reader to the specified path.
    // Returns object metadata on success.
    Put(path string, reader io.Reader) (*Object, error)

    // Delete removes the file at the specified path.
    // Returns nil if file doesn't exist or was successfully deleted.
    Delete(path string) error

    // List returns all objects under the specified path prefix.
    // Returns empty slice if no objects found.
    List(path string) ([]*Object, error)

    // GetURL generates a presigned URL for downloading the file.
    // URL is typically valid for 1 hour.
    GetURL(path string) (string, error)

    // GetEndpoint returns the storage service endpoint URL.
    GetEndpoint() string

    // Exists checks if an object exists at the specified path.
    Exists(path string) (bool, error)

    // Stat retrieves object metadata without downloading content.
    Stat(path string) (*Object, error)
}
Object
type Object struct {
    Path             string     // File path in storage
    Name             string     // File name
    LastModified     *time.Time // Last modification time
    Size             int64      // File size in bytes
    StorageInterface Interface  // Associated storage interface
}
Config
type Config struct {
    Provider           string // Storage provider: s3, minio, aliyun, azure, tencent, qiniu, gcs, synology, filesystem
    ID                 string // Access key ID / Account name
    Secret             string // Secret access key / Account key
    Region             string // Region (required for cloud storage)
    Bucket             string // Bucket name / Container name / Local path
    Endpoint           string // Custom endpoint (required for MinIO, Synology)
    ServiceAccountJSON string // Service account JSON file path for GCS
    AppID              string // Tencent COS Application ID
    Debug              bool   // Enable debug mode
}

Advanced Usage

List Files
objects, err := storage.List("images/")
if err != nil {
    panic(err)
}

for _, obj := range objects {
    fmt.Printf("File: %s, Size: %d bytes\n", obj.Path, obj.Size)
}
Check File Existence
exists, err := storage.Exists("file.txt")
if err != nil {
    panic(err)
}

if exists {
    fmt.Println("File exists")
} else {
    fmt.Println("File does not exist")
}
Get File Metadata
obj, err := storage.Stat("document.pdf")
if err != nil {
    panic(err)
}

fmt.Printf("File: %s\n", obj.Name)
fmt.Printf("Size: %d bytes\n", obj.Size)
fmt.Printf("Last Modified: %s\n", obj.LastModified)
Stream Download
reader, err := storage.GetStream("large-file.zip")
if err != nil {
    panic(err)
}
defer reader.Close()

// Process the stream...

Custom Drivers

Implement the Driver interface to add support for new storage providers:

type Driver interface {
    // Name returns the driver name.
    Name() string

    // Connect establishes a connection to the storage service.
    Connect(ctx context.Context, cfg *Config) (Interface, error)

    // Close closes the storage connection.
    Close(conn Interface) error
}

Register your driver in an init() function:

func init() {
    oss.RegisterDriver(&myDriver{})
}

Migration from ncore/data/storage

If you are upgrading from an older version:

// Old Code
import "github.com/ncobase/ncore/data/storage"

// New Code
import "github.com/ncobase/ncore/oss"

License

See the LICENSE file for details.

Contributing

Pull requests and issues are welcome!

Documentation

Overview

Package oss provides a unified object storage abstraction layer supporting multiple cloud storage providers including AWS S3, Azure Blob, Aliyun OSS, Tencent COS, Google Cloud Storage, MinIO, Qiniu Kodo, Synology NAS, and local filesystem.

All providers implement a common Interface for consistent operations across different storage backends. Drivers are auto-registered via init() functions, enabling transparent provider selection at runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDriver

func RegisterDriver(driver Driver)

RegisterDriver registers a storage driver. Typically called in the driver package's init function.

Types

type AliyunAdapter

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

AliyunAdapter implements the Interface for Aliyun OSS storage.

func NewAliyunAdapter

func NewAliyunAdapter(accessKeyID, secretAccessKey, region, bucket, endpoint string) (*AliyunAdapter, error)

NewAliyunAdapter creates a new Aliyun OSS storage adapter.

func (*AliyunAdapter) Delete

func (a *AliyunAdapter) Delete(path string) error

Delete removes an object from the Aliyun OSS bucket.

func (*AliyunAdapter) Exists added in v0.2.3

func (a *AliyunAdapter) Exists(path string) (bool, error)

Exists checks if an object exists in the Aliyun OSS bucket.

func (*AliyunAdapter) Get

func (a *AliyunAdapter) Get(path string) (*os.File, error)

Get downloads a file from Aliyun OSS to a temporary local file.

func (*AliyunAdapter) GetEndpoint

func (a *AliyunAdapter) GetEndpoint() string

GetEndpoint returns the Aliyun OSS endpoint URL.

func (*AliyunAdapter) GetStream

func (a *AliyunAdapter) GetStream(path string) (io.ReadCloser, error)

GetStream returns a readable stream for the Aliyun OSS object.

func (*AliyunAdapter) GetURL

func (a *AliyunAdapter) GetURL(path string) (string, error)

GetURL generates a presigned URL valid for 1 hour.

func (*AliyunAdapter) List

func (a *AliyunAdapter) List(path string) ([]*Object, error)

List returns all objects under the specified prefix.

func (*AliyunAdapter) Put

func (a *AliyunAdapter) Put(path string, reader io.Reader) (*Object, error)

Put uploads a file to Aliyun OSS from the given reader.

func (*AliyunAdapter) Stat added in v0.2.3

func (a *AliyunAdapter) Stat(path string) (*Object, error)

Stat retrieves object metadata without downloading content.

type AzureAdapter

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

AzureAdapter implements the Interface for Azure Blob Storage.

func NewAzureAdapter

func NewAzureAdapter(accountName, accountKey, containerName string) (*AzureAdapter, error)

NewAzureAdapter creates a new Azure Blob Storage adapter.

func (*AzureAdapter) Delete

func (a *AzureAdapter) Delete(path string) error

Delete removes a blob from the Azure container.

func (*AzureAdapter) Exists added in v0.2.3

func (a *AzureAdapter) Exists(path string) (bool, error)

Exists checks if a blob exists in the Azure container.

func (*AzureAdapter) Get

func (a *AzureAdapter) Get(path string) (*os.File, error)

Get downloads a blob from Azure to a temporary local file.

func (*AzureAdapter) GetEndpoint

func (a *AzureAdapter) GetEndpoint() string

GetEndpoint returns the Azure Blob Storage endpoint URL.

func (*AzureAdapter) GetStream

func (a *AzureAdapter) GetStream(path string) (io.ReadCloser, error)

GetStream returns a readable stream for the Azure blob.

func (*AzureAdapter) GetURL

func (a *AzureAdapter) GetURL(path string) (string, error)

GetURL generates a SAS URL valid for 1 hour.

func (*AzureAdapter) List

func (a *AzureAdapter) List(path string) ([]*Object, error)

List returns all blobs under the specified prefix.

func (*AzureAdapter) Put

func (a *AzureAdapter) Put(path string, reader io.Reader) (*Object, error)

Put uploads a file to Azure Blob Storage from the given reader.

func (*AzureAdapter) Stat added in v0.2.3

func (a *AzureAdapter) Stat(path string) (*Object, error)

Stat retrieves blob metadata without downloading content.

type Config

type Config struct {
	Provider           string `json:"provider" yaml:"provider"`                                             // Storage provider: minio, s3, aliyun, azure, tencent, qiniu, gcs, synology, filesystem
	ID                 string `json:"id" yaml:"id"`                                                         // Access key ID / Account name
	Secret             string `json:"secret" yaml:"secret"`                                                 // Secret access key / Account key
	Region             string `json:"region" yaml:"region"`                                                 // Region (required for cloud storage)
	Bucket             string `json:"bucket" yaml:"bucket"`                                                 // Bucket name / Container name / Local path
	Endpoint           string `json:"endpoint" yaml:"endpoint"`                                             // Custom endpoint (required for MinIO, Synology)
	ServiceAccountJSON string `json:"service_account_json,omitempty" yaml:"service_account_json,omitempty"` // Service account JSON file path for Google Cloud Storage
	SharedFolder       string `json:"shared_folder,omitempty" yaml:"shared_folder,omitempty"`               // Synology shared folder (optional)
	OtpCode            string `json:"otp_code,omitempty" yaml:"otp_code,omitempty"`                         // Synology 2FA code (optional)
	Debug              bool   `json:"debug,omitempty" yaml:"debug,omitempty"`                               // Enable debug mode (optional)
	AppID              string `json:"app_id,omitempty" yaml:"app_id,omitempty"`                             // Tencent COS Application ID
}

Config holds configuration for object storage providers.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid and sets default values where applicable.

type Driver

type Driver interface {
	// Name returns the driver name.
	Name() string

	// Connect establishes a connection to the storage service.
	Connect(ctx context.Context, cfg *Config) (Interface, error)

	// Close closes the storage connection.
	Close(conn Interface) error
}

Driver defines the storage driver interface. Implement this interface to add support for new storage providers.

func GetDriver

func GetDriver(name string) (Driver, error)

GetDriver retrieves a driver by name. Returns an error if the driver is not registered.

type FileSystem

type FileSystem interface {
	GetFullPath(p string) string
	Get(p string) (*os.File, error)
	GetStream(p string) (io.ReadCloser, error)
	Put(p string, r io.Reader) (*Object, error)
	Delete(p string) error
	List(p string) ([]*Object, error)
	GetEndpoint() string
	GetURL(p string) (string, error)
}

FileSystem represents the interface for file system storage

type GCSAdapter

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

GCSAdapter implements the Interface for Google Cloud Storage.

func NewGCSAdapter

func NewGCSAdapter(serviceAccountJSON, bucket string) (*GCSAdapter, error)

NewGCSAdapter creates a new Google Cloud Storage adapter.

func (*GCSAdapter) Delete

func (a *GCSAdapter) Delete(path string) error

Delete removes an object from the GCS bucket.

func (*GCSAdapter) Exists added in v0.2.3

func (a *GCSAdapter) Exists(path string) (bool, error)

Exists checks if an object exists in the GCS bucket.

func (*GCSAdapter) Get

func (a *GCSAdapter) Get(path string) (*os.File, error)

Get downloads an object from GCS to a temporary local file.

func (*GCSAdapter) GetEndpoint

func (a *GCSAdapter) GetEndpoint() string

GetEndpoint returns the Google Cloud Storage endpoint URL.

func (*GCSAdapter) GetStream

func (a *GCSAdapter) GetStream(path string) (io.ReadCloser, error)

GetStream returns a readable stream for the GCS object.

func (*GCSAdapter) GetURL

func (a *GCSAdapter) GetURL(path string) (string, error)

GetURL generates a signed URL valid for 1 hour.

func (*GCSAdapter) List

func (a *GCSAdapter) List(path string) ([]*Object, error)

List returns all objects under the specified prefix.

func (*GCSAdapter) Put

func (a *GCSAdapter) Put(path string, reader io.Reader) (*Object, error)

Put uploads a file to GCS from the given reader.

func (*GCSAdapter) Stat added in v0.2.3

func (a *GCSAdapter) Stat(path string) (*Object, error)

Stat retrieves object metadata without downloading content.

type Interface

type Interface interface {
	// Get downloads a file to a temporary file and returns the file handle.
	// Caller is responsible for closing the file and removing it when done.
	Get(path string) (*os.File, error)

	// GetStream returns a readable stream for streaming large file downloads.
	// Caller is responsible for closing the reader when done.
	GetStream(path string) (io.ReadCloser, error)

	// Put uploads a file from the given reader to the specified path.
	// Returns object metadata on success.
	Put(path string, reader io.Reader) (*Object, error)

	// Delete removes the file at the specified path.
	// Returns nil if file doesn't exist or was successfully deleted.
	Delete(path string) error

	// List returns all objects under the specified path prefix.
	// Returns empty slice if no objects found.
	List(path string) ([]*Object, error)

	// GetURL generates a presigned URL for downloading the file.
	// URL is typically valid for 1 hour.
	GetURL(path string) (string, error)

	// GetEndpoint returns the storage service endpoint URL.
	GetEndpoint() string

	// Exists checks if an object exists at the specified path.
	Exists(path string) (bool, error)

	// Stat retrieves object metadata without downloading content.
	Stat(path string) (*Object, error)
}

Interface defines unified object storage operations. All storage providers implement this interface for consistent API access.

func NewStorage

func NewStorage(c *Config) (Interface, error)

NewStorage creates a storage instance based on the provided configuration. Automatically selects the appropriate storage provider.

type LocalFileSystem

type LocalFileSystem struct {
	Folder string
}

LocalFileSystem implements the FileSystem interface for local file system storage

func NewFileSystem

func NewFileSystem(folder string) *LocalFileSystem

NewFileSystem creates a new local file system storage

func (*LocalFileSystem) Delete

func (fs *LocalFileSystem) Delete(p string) error

Delete deletes a file

func (*LocalFileSystem) Exists added in v0.2.3

func (fs *LocalFileSystem) Exists(p string) (bool, error)

Exists checks if a file exists at the specified path.

func (*LocalFileSystem) Get

func (fs *LocalFileSystem) Get(p string) (*os.File, error)

Get receives a file with the given path

func (*LocalFileSystem) GetEndpoint

func (fs *LocalFileSystem) GetEndpoint() string

GetEndpoint gets the endpoint (for FileSystem, it's just the base path)

func (*LocalFileSystem) GetFullPath

func (fs *LocalFileSystem) GetFullPath(p string) string

GetFullPath returns the full path from absolute/relative path

func (*LocalFileSystem) GetStream

func (fs *LocalFileSystem) GetStream(p string) (io.ReadCloser, error)

GetStream gets a file as a stream

func (*LocalFileSystem) GetURL

func (fs *LocalFileSystem) GetURL(p string) (string, error)

GetURL returns the public accessible URL. For local filesystem, returns the relative path.

func (*LocalFileSystem) List

func (fs *LocalFileSystem) List(p string) ([]*Object, error)

List lists files

func (*LocalFileSystem) Put

func (fs *LocalFileSystem) Put(p string, r io.Reader) (*Object, error)

Put stores the reader into the given path

func (*LocalFileSystem) Stat added in v0.2.3

func (fs *LocalFileSystem) Stat(p string) (*Object, error)

Stat retrieves file metadata without reading content.

type MinioAdapter

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

MinioAdapter implements the Interface for MinIO object storage. Compatible with any S3-compatible storage service.

func NewMinioAdapter

func NewMinioAdapter(endpoint, accessKeyID, secretAccessKey, bucket string, useSSL bool) (*MinioAdapter, error)

NewMinioAdapter creates a new MinIO storage adapter.

func (*MinioAdapter) Delete

func (a *MinioAdapter) Delete(path string) error

Delete removes an object from the MinIO bucket.

func (*MinioAdapter) Exists added in v0.2.3

func (a *MinioAdapter) Exists(path string) (bool, error)

Exists checks if an object exists in the MinIO bucket.

func (*MinioAdapter) Get

func (a *MinioAdapter) Get(path string) (*os.File, error)

Get downloads a file from MinIO to a temporary local file.

func (*MinioAdapter) GetEndpoint

func (a *MinioAdapter) GetEndpoint() string

GetEndpoint returns the MinIO endpoint URL.

func (*MinioAdapter) GetStream

func (a *MinioAdapter) GetStream(path string) (io.ReadCloser, error)

GetStream returns a readable stream for the MinIO object.

func (*MinioAdapter) GetURL

func (a *MinioAdapter) GetURL(path string) (string, error)

GetURL generates a presigned URL valid for 1 hour.

func (*MinioAdapter) List

func (a *MinioAdapter) List(path string) ([]*Object, error)

List returns all objects under the specified prefix.

func (*MinioAdapter) Put

func (a *MinioAdapter) Put(path string, reader io.Reader) (*Object, error)

Put uploads a file to MinIO from the given reader.

func (*MinioAdapter) Stat added in v0.2.3

func (a *MinioAdapter) Stat(path string) (*Object, error)

Stat retrieves object metadata without downloading content.

type Object

type Object struct {
	Path             string     // File path in storage
	Name             string     // File name
	LastModified     *time.Time // Last modification time
	Size             int64      // File size in bytes
	StorageInterface Interface  // Associated storage interface
}

Object represents metadata about a stored object.

func (Object) Get

func (object Object) Get() (*os.File, error)

Get retrieves the file for this object. This is a convenience method that calls the associated storage interface's Get method.

type QiniuAdapter

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

QiniuAdapter implements the Interface for Qiniu Kodo storage.

func NewQiniuAdapter

func NewQiniuAdapter(accessKey, secretKey, bucket, region, domain string) (*QiniuAdapter, error)

NewQiniuAdapter creates a new Qiniu Kodo storage adapter.

func (*QiniuAdapter) Delete

func (a *QiniuAdapter) Delete(path string) error

Delete removes an object from the Qiniu bucket.

func (*QiniuAdapter) Exists added in v0.2.3

func (a *QiniuAdapter) Exists(path string) (bool, error)

Exists checks if an object exists in the Qiniu bucket.

func (*QiniuAdapter) Get

func (a *QiniuAdapter) Get(path string) (*os.File, error)

Get downloads a file from Qiniu to a temporary local file.

func (*QiniuAdapter) GetEndpoint

func (a *QiniuAdapter) GetEndpoint() string

GetEndpoint returns the Qiniu Kodo endpoint URL.

func (*QiniuAdapter) GetStream

func (a *QiniuAdapter) GetStream(path string) (io.ReadCloser, error)

GetStream returns a readable stream for the Qiniu object.

func (*QiniuAdapter) GetURL

func (a *QiniuAdapter) GetURL(path string) (string, error)

GetURL generates a private signed URL valid for 1 hour.

func (*QiniuAdapter) List

func (a *QiniuAdapter) List(path string) ([]*Object, error)

List returns all objects under the specified prefix.

func (*QiniuAdapter) Put

func (a *QiniuAdapter) Put(path string, reader io.Reader) (*Object, error)

Put uploads a file to Qiniu from the given reader.

func (*QiniuAdapter) Stat added in v0.2.3

func (a *QiniuAdapter) Stat(path string) (*Object, error)

Stat retrieves object metadata without downloading content.

type S3Adapter

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

S3Adapter implements the Interface for AWS S3 storage. Supports both AWS S3 and S3-compatible services with custom endpoints.

func NewS3Adapter

func NewS3Adapter(accessKeyID, secretAccessKey, region, bucket, endpoint string) (*S3Adapter, error)

NewS3Adapter creates a new S3 storage adapter. For S3-compatible services, set the endpoint parameter.

func (*S3Adapter) Delete

func (a *S3Adapter) Delete(path string) error

Delete removes an object from the S3 bucket.

func (*S3Adapter) Exists added in v0.2.3

func (a *S3Adapter) Exists(path string) (bool, error)

Exists checks if an object exists in the S3 bucket.

func (*S3Adapter) Get

func (a *S3Adapter) Get(path string) (*os.File, error)

Get downloads a file from S3 to a temporary local file.

func (*S3Adapter) GetEndpoint

func (a *S3Adapter) GetEndpoint() string

GetEndpoint returns the S3 endpoint URL.

func (*S3Adapter) GetStream

func (a *S3Adapter) GetStream(path string) (io.ReadCloser, error)

GetStream returns a readable stream for the S3 object.

func (*S3Adapter) GetURL

func (a *S3Adapter) GetURL(path string) (string, error)

GetURL generates a presigned URL valid for 1 hour.

func (*S3Adapter) List

func (a *S3Adapter) List(path string) ([]*Object, error)

List returns all objects under the specified prefix.

func (*S3Adapter) Put

func (a *S3Adapter) Put(path string, reader io.Reader) (*Object, error)

Put uploads a file to S3 from the given reader.

func (*S3Adapter) Stat added in v0.2.3

func (a *S3Adapter) Stat(path string) (*Object, error)

Stat retrieves object metadata without downloading content.

type SynologyAdapter

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

SynologyAdapter implements the Interface for Synology NAS S3-compatible storage.

func NewSynologyAdapter

func NewSynologyAdapter(endpoint, accessKey, secretKey, bucket string, useSSL bool) (*SynologyAdapter, error)

NewSynologyAdapter creates a new Synology NAS storage adapter.

func (*SynologyAdapter) Delete

func (a *SynologyAdapter) Delete(path string) error

Delete removes an object from the Synology bucket.

func (*SynologyAdapter) Exists added in v0.2.3

func (a *SynologyAdapter) Exists(path string) (bool, error)

Exists checks if an object exists in the Synology bucket.

func (*SynologyAdapter) Get

func (a *SynologyAdapter) Get(path string) (*os.File, error)

Get downloads a file from Synology to a temporary local file.

func (*SynologyAdapter) GetEndpoint

func (a *SynologyAdapter) GetEndpoint() string

GetEndpoint returns the Synology NAS endpoint URL.

func (*SynologyAdapter) GetStream

func (a *SynologyAdapter) GetStream(path string) (io.ReadCloser, error)

GetStream returns a readable stream for the Synology object.

func (*SynologyAdapter) GetURL

func (a *SynologyAdapter) GetURL(path string) (string, error)

GetURL generates a presigned URL valid for 1 hour.

func (*SynologyAdapter) List

func (a *SynologyAdapter) List(path string) ([]*Object, error)

List returns all objects under the specified prefix.

func (*SynologyAdapter) Put

func (a *SynologyAdapter) Put(path string, reader io.Reader) (*Object, error)

Put uploads a file to Synology from the given reader.

func (*SynologyAdapter) Stat added in v0.2.3

func (a *SynologyAdapter) Stat(path string) (*Object, error)

Stat retrieves object metadata without downloading content.

type TencentAdapter

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

TencentAdapter implements the Interface for Tencent Cloud Object Storage (COS).

func NewTencentAdapter

func NewTencentAdapter(secretID, secretKey, region, bucket, appID string) (*TencentAdapter, error)

NewTencentAdapter creates a new Tencent COS storage adapter.

func (*TencentAdapter) Delete

func (a *TencentAdapter) Delete(path string) error

Delete removes an object from the Tencent COS bucket.

func (*TencentAdapter) Exists added in v0.2.3

func (a *TencentAdapter) Exists(path string) (bool, error)

Exists checks if an object exists in the Tencent COS bucket.

func (*TencentAdapter) Get

func (a *TencentAdapter) Get(path string) (*os.File, error)

Get downloads a file from Tencent COS to a temporary local file.

func (*TencentAdapter) GetEndpoint

func (a *TencentAdapter) GetEndpoint() string

GetEndpoint returns the Tencent COS endpoint URL.

func (*TencentAdapter) GetStream

func (a *TencentAdapter) GetStream(path string) (io.ReadCloser, error)

GetStream returns a readable stream for the Tencent COS object.

func (*TencentAdapter) GetURL

func (a *TencentAdapter) GetURL(path string) (string, error)

GetURL generates a presigned URL valid for 1 hour.

func (*TencentAdapter) List

func (a *TencentAdapter) List(path string) ([]*Object, error)

List returns all objects under the specified prefix.

func (*TencentAdapter) Put

func (a *TencentAdapter) Put(path string, reader io.Reader) (*Object, error)

Put uploads a file to Tencent COS from the given reader.

func (*TencentAdapter) Stat added in v0.2.3

func (a *TencentAdapter) Stat(path string) (*Object, error)

Stat retrieves object metadata without downloading content.

Jump to

Keyboard shortcuts

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