gofs

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 4 Imported by: 3

README

GOFS - Storage Provider

GOFS aims to provide the same API with multiple backend storages such as Local, S3, ...

Examples

A basic example to list files with an S3 Backend:

config := s3.S3Config{
    Endpoint:        "localhost:9000",
    Region:          "us-east-1",
    AccessKeyID:     "minioaccesskey",
    SecretAccessKey: "miniosecretkey",
    UseSSL:          false,
    BucketName:      "gofs-test",
    PathPrefix:      "test/",
    Debug:           true,
}

log.Println("Initializing backend ...")
goFS, err := gofs.New(gofs.BACKEND_TYPE_S3, config)
if err != nil {
    log.Fatal("GOSF Backend initialization error : " + err.Error())
}
log.Println("Backend initialized")

log.Println("Listing all files recursively ...")
currentFiles, err := goFS.List("", true)
if err != nil {
    log.Fatal("Unable to list files : " + err.Error())
}
for _, filePath := range currentFiles {
    log.Printf("\t %s\n", filePath)
}
log.Println("Files listing end")

Other full examples are available in cmd/gosflocal & cmd/gofss3 folders


TODO

Global
  • Add an in-memory cache system for small files (local and/or shared)
  • Improve logging messages and error handling
  • Add the ability to retreive a file partially (by bytes range)
  • Add unit tests
  • Add other storage backends ? (Azure Blob, GCP Storage, Swift, ...)
Local Backend
  • Add Mutex to handle simultaneous file Read/Write conflicts

License

MIT, see LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoFS

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

func New

func New(backendType GoFSBackendType, backendConfig interface{}) (GoFS, error)

func (*GoFS) Delete

func (gfs *GoFS) Delete(filepath string) error

func (*GoFS) List

func (gfs *GoFS) List(path string, recursive bool) ([]string, error)

func (*GoFS) Move

func (gfs *GoFS) Move(filepathSrc string, filepathDst string) error

func (*GoFS) Read

func (gfs *GoFS) Read(filepath string) ([]byte, error)

func (*GoFS) ReadString

func (gfs *GoFS) ReadString(filepath string) (string, error)

func (*GoFS) Stat

func (gfs *GoFS) Stat(filepath string) (backend.FileInfo, error)

func (*GoFS) Write

func (gfs *GoFS) Write(filepath string, data []byte) error

func (*GoFS) WriteString

func (gfs *GoFS) WriteString(filepath string, content string) error

type GoFSBackendType

type GoFSBackendType string
const (
	BACKEND_TYPE_LOCAL GoFSBackendType = gofsbcklocal.BACKEND_NAME
	BACKEND_TYPE_S3    GoFSBackendType = gofsbcks3.BACKEND_NAME
)

Directories

Path Synopsis
cmd
internal
pkg

Jump to

Keyboard shortcuts

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