flysystem

package module
v0.0.0-...-d6e1c3b Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: MIT Imports: 3 Imported by: 0

README

Go Flysystem

GitHub go.mod Go version Go Reference Build Status Maintainability Test Coverage

Go Flysystem is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one.

Inspired by: https://github.com/thephpleague/flysystem

Installation

go get github.com/edwin-luijten/go_flysystem

Usage

Adapters
import (
    "github.com/edwin-luijten/go_flysystem/adapter"
)

func main() {
    a, err := adapter.NewLocal("./_testdata")
    if err != nil {
    	panic(err)
    }
    
    // Write
    err = a.Write("test.txt", []byte("hello"))
    if err != nil {
        t.Log(err)
        t.Fail()
    }
}
Multiple adapters
import (
    "github.com/edwin-luijten/go_flysystem/adapter"
)

func main() {
    a, err := adapter.NewLocal("./_testdata")
    if err != nil {
    	panic(err)
    }
    
    b, err = adapter.NewLocal("./_testdata")
    if err != nil {
        panic(err)
    }
    
    fs, err = flysystem.New(a, b)
    
    // Write
    err = fs.Write("test.txt", []byte("hello"))
    if err != nil {
        t.Log(err)
        t.Fail()
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flysystem

type Flysystem struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Flysystem ...

func New

func New(adapters ...adapter.Adapter) *Flysystem

New creates a new instance with given adapters

func (*Flysystem) Copy

func (f *Flysystem) Copy(path string, newPath string) error

Copy a file

func (*Flysystem) CreateDir

func (f *Flysystem) CreateDir(dir string) error

CreateDir creates a directory

func (*Flysystem) Delete

func (f *Flysystem) Delete(path string) error

Delete a file

func (*Flysystem) DeleteDir

func (f *Flysystem) DeleteDir(dir string) error

DeleteDir deletes a directory

func (*Flysystem) Read

func (f *Flysystem) Read(path string) ([]byte, error)

Read a file

func (*Flysystem) Rename

func (f *Flysystem) Rename(path string, newPath string) error

Rename a file

func (*Flysystem) SetVisibility

func (f *Flysystem) SetVisibility(path string, visibility string) error

SetVisibility sets a file or directory to public or private

func (*Flysystem) Update

func (f *Flysystem) Update(path string, contents []byte) error

Update a file

func (*Flysystem) Write

func (f *Flysystem) Write(path string, contents []byte) error

Write a new file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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