simplecloud

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: MIT Imports: 16 Imported by: 2

README

simplecloud

A tiny Go package for reading and writing objects in different “bucket” backends with a unified interface. Supports local files, HTTP(s), Backblaze B2, and Google Cloud Storage (GCS).


Features

  • Unified API for cloud and local storage
  • Backends supported:
    • Local filesystem (file:// or bare paths)
    • HTTP(s) (read-only)
    • Backblaze B2 (b2://bucket)
    • Google Cloud Storage (gs://bucket)
  • Transparent compression: .gz, .bz2, .xz auto-detected for reads/writes
  • Simple resource lifecycle: readers/writers are io.ReadCloser / io.WriteCloser
  • Tiny core: no extra abstractions beyond what you need

Install

go get github.com/mtgban/simplecloud

Status

This is a lightweight helper, not a full-featured SDK. Good for:

  • simple pipelines
  • moving files between backends
  • quick prototypes

Not a replacement for full cloud SDKs (retry logic, ACLs, advanced features).


License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy added in v0.0.5

func Copy(ctx context.Context, src Reader, dst Writer, srcPath, dstPath string) (int64, error)

func InitReader

func InitReader(ctx context.Context, bucket Reader, path string) (io.ReadCloser, error)

func InitWriter

func InitWriter(ctx context.Context, bucket Writer, path string) (io.WriteCloser, error)

Types

type B2Bucket

type B2Bucket struct {
	Bucket *b2.Bucket

	ConcurrentDownloads int
}

func NewB2Client

func NewB2Client(ctx context.Context, accessKey, secretKey, bucketName string) (*B2Bucket, error)

func (*B2Bucket) NewReader

func (b *B2Bucket) NewReader(ctx context.Context, path string) (io.ReadCloser, error)

func (*B2Bucket) NewWriter

func (b *B2Bucket) NewWriter(ctx context.Context, path string) (io.WriteCloser, error)

type FileBucket

type FileBucket struct{}

func (*FileBucket) NewReader

func (f *FileBucket) NewReader(ctx context.Context, path string) (io.ReadCloser, error)

func (*FileBucket) NewWriter added in v0.0.2

func (f *FileBucket) NewWriter(ctx context.Context, path string) (io.WriteCloser, error)

type GCSBucket

type GCSBucket struct {
	Bucket *storage.BucketHandle
}

func NewGCSClient

func NewGCSClient(ctx context.Context, serviceAccountFile, bucketName string) (*GCSBucket, error)

func (*GCSBucket) NewReader

func (g *GCSBucket) NewReader(ctx context.Context, path string) (io.ReadCloser, error)

func (*GCSBucket) NewWriter

func (g *GCSBucket) NewWriter(ctx context.Context, path string) (io.WriteCloser, error)

type HTTPBucket

type HTTPBucket struct {
	Client *http.Client
	URL    *url.URL
}

func NewHTTPBucket

func NewHTTPBucket(client *http.Client, path string) (*HTTPBucket, error)

func (*HTTPBucket) NewReader

func (h *HTTPBucket) NewReader(ctx context.Context, path string) (io.ReadCloser, error)

type MultiCloser

type MultiCloser struct {
	io.Reader
	io.Writer
	// contains filtered or unexported fields
}

func (*MultiCloser) Close

func (m *MultiCloser) Close() error

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

type Reader

type Reader interface {
	NewReader(context.Context, string) (io.ReadCloser, error)
}

type Writer

type Writer interface {
	NewWriter(context.Context, string) (io.WriteCloser, error)
}

Jump to

Keyboard shortcuts

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