s3fsrw

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

README

s3fsrw

s3fsrw is a wrapper for Amazon S3-compatible object storage, implementing the writefs.FullFS interface.

Features

  • S3 Compatibility: Works with Amazon S3, MinIO, and other S3-compatible storage systems.
  • Read/Write Operations: Supports Create, Append, Remove, Rename (via copy and delete), and WriteFile.
  • Directory Emulation: Provides a flat directory structure typical for object storage.
  • Metadata Management: Handles object metadata and content-types.

Usage

import (
	"github.com/je4/filesystem/v3/pkg/s3fsrw"
	"github.com/je4/utils/v2/pkg/zLogger"
)

// Initialize with S3 credentials
fsys, err := s3fsrw.NewFS(
    "s3.example.com", 
    "accessKey", 
    "secretKey", 
    "us-east-1", 
    true, // useSSL
    false, // debug
    nil, // tlsConfig
    "", // dnsNetwork
    "", // dnsAddress
    false, // readOnly
    logger,
)
if err != nil {
	// handle error
}

// Write to an S3 object
err = fsys.Create("mybucket/data/file.txt")

Documentation

Index

Constants

View Source
const (
	JustURL debugLevel = iota
	URLTiming
	CurlCommand
	RequestHeaders
	ResponseStatus
	ResponseHeaders
)

Variables

View Source
var ARNRegexStr = `^arn:(?P<partition>[^:]*):s3:(?P<region>[^:]*):(?P<namespace>[^:]*):(?P<subpath>[^:]*)`

Functions

func NewCreateFSFunc

func NewCreateFSFunc(access map[string]*S3Access, regexpString string, debug bool, tlsConfig *tls.Config, dnsNetwork, dnsAddress string, logger zLogger.ZLogger) writefs.CreateFSFunc

func NewDebuggingRoundTripper

func NewDebuggingRoundTripper(rt http.RoundTripper, logger zLogger.ZWrapper, levels ...debugLevel) *debuggingRoundTripper

func NewFS

func NewFS(endpoint, accessKeyID, secretAccessKey, region string, useSSL, debug bool, tlsConfig *tls.Config, dnsNetwork, dnsAddress string, readOnly bool, logger zLogger.ZLogger) (*s3FSRW, error)

func NewFileInfo

func NewFileInfo(o *minio.ObjectInfo) fs.FileInfo

func NewUploadInfo

func NewUploadInfo(ui *minio.UploadInfo, err error) *uploadInfo

func NewWriteCloser

func NewWriteCloser(debugInfo string, logger zLogger.ZWrapper) *rwCloser

Types

type ROFile

type ROFile struct {
	*minio.Object
	// contains filtered or unexported fields
}

func NewROFile

func NewROFile(o *minio.Object, debugInfo string, logger zLogger.ZWrapper) *ROFile

func (*ROFile) Close

func (s3f *ROFile) Close() error

func (*ROFile) Stat

func (s3f *ROFile) Stat() (fs.FileInfo, error)

type S3Access

type S3Access struct {
	AccessKey string
	SecretKey string
	URL       string
	UseSSL    bool
}

Jump to

Keyboard shortcuts

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