rclonefs

package
v0.0.0-...-75e7317 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 18 Imported by: 0

README

S3 Driver

The s3 driver provides functionality to store and retrieve files using various object storage solutions, including MinIO, AWS S3, and more.

MinIO Provider

Below is a description of how to use and configure the Minio provider.

Features
  • File upload and retrieval from multiple object storage providers
  • URL generation for stored files
  • Integration with fastschema's fs.Disk interface
Configuration

To use the Minio provider, configure it with your storage settings. Here's an example of how to set up the STORAGE environment variable for a MinIO configuration:

[
 {
 "name": "my_minio",
 "driver": "s3",
 "root": "/files",
 "provider": "Minio",
 "endpoint": "http://localhost:9000",
 "region": "",
 "bucket": "fastschematest",
 "access_key_id": "access_key_id",
 "secret_access_key": "secret_access_key",
 "base_url": "https://cdn.site.local"
 }
]
Important Security Considerations
  1. Public Read Access: This package is designed to serve files that will be publicly accessible (e.g., for a blog or similar applications). Configure your storage bucket to allow public read access for stored objects.
  2. Bucket Creation: Create the storage bucket manually and configure it for public read access, but not public write access.
  3. Public Nature of Files: Files stored using this package will be publicly accessible. Avoid storing sensitive or private information without additional security measures.
  4. Write Access: Only your application should have write permissions to the bucket.
Disclaimer

This package is designed for use cases where public read access to stored files is acceptable. For private or sensitive information, implement additional security measures or use a different storage solution.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFromConfig

func NewFromConfig(diskConfigs []*fs.DiskConfig, localRoot string) ([]fs.Disk, error)

func NewLocal

func NewLocal(config *RcloneLocalConfig) (fs.Disk, error)

func NewS3

func NewS3(config *RcloneS3Config) (fs.Disk, error)

Types

type BaseRcloneDisk

type BaseRcloneDisk struct {
	rclonefs.Fs
	Disk           string `json:"name"`
	GetURL         func(string) string
	UploadFilePath func(string) string
	IsAllowedMime  func(string) bool
}

func (*BaseRcloneDisk) Delete

func (r *BaseRcloneDisk) Delete(ctx context.Context, filePath string) error

func (*BaseRcloneDisk) Put

func (r *BaseRcloneDisk) Put(ctx context.Context, file *fs.File) (*fs.File, error)

func (*BaseRcloneDisk) PutMultipart

func (r *BaseRcloneDisk) PutMultipart(
	ctx context.Context,
	m *multipart.FileHeader,
	dsts ...string,
) (*fs.File, error)

func (*BaseRcloneDisk) PutReader

func (r *BaseRcloneDisk) PutReader(
	ctx context.Context,
	reader io.Reader,
	size uint64,
	fileType,
	dst string,
) (*fs.File, error)

type RcloneLocal

type RcloneLocal struct {
	*fs.DiskBase
	*BaseRcloneDisk
	// contains filtered or unexported fields
}

func (*RcloneLocal) LocalPublicPath

func (r *RcloneLocal) LocalPublicPath() string

func (*RcloneLocal) Root

func (r *RcloneLocal) Root() string

func (*RcloneLocal) URL

func (r *RcloneLocal) URL(filepath string) string

type RcloneLocalConfig

type RcloneLocalConfig struct {
	Name       string        `json:"name"`
	Root       string        `json:"root"`
	BaseURL    string        `json:"base_url"`
	PublicPath string        `json:"public_path"`
	GetBaseURL func() string `json:"-"`
}

type RcloneS3

type RcloneS3 struct {
	*fs.DiskBase
	*BaseRcloneDisk
	// contains filtered or unexported fields
}

func (*RcloneS3) LocalPublicPath

func (r *RcloneS3) LocalPublicPath() string

func (*RcloneS3) Root

func (r *RcloneS3) Root() string

func (*RcloneS3) URL

func (r *RcloneS3) URL(filepath string) string

type RcloneS3Config

type RcloneS3Config struct {
	Name            string              `json:"name"`
	Root            string              `json:"root"`
	Provider        string              `json:"provider"`
	Bucket          string              `json:"bucket"`
	Region          string              `json:"region"`
	Endpoint        string              `json:"endpoint"`
	ChunkSize       rclonefs.SizeSuffix `json:"chunk_size"`
	CopyCutoff      rclonefs.SizeSuffix `json:"copy_cutoff"`
	AccessKeyID     string              `json:"access_key_id"`
	SecretAccessKey string              `json:"secret_access_key"`
	BaseURL         string              `json:"base_url"`
	ACL             string              `json:"acl"`
}

Jump to

Keyboard shortcuts

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