s3fs

package module
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: MIT Imports: 15 Imported by: 0

README

s3fs Go Reference Go

Package s3fs provides a S3 implementation for Go1.16 filesystem interface.

Since S3 is a flat structure, s3fs simulates directories by using prefixes and "/" delim. ModTime on directories is always zero value.

The implementation wraps aws sdk go s3 client.

const bucket = "my-bucket"

s, err := session.NewSession()
if err != nil {
    log.Fatal(err)
}

s3fs := s3fs.New(s3.New(s), bucket)

// print out all files in s3 bucket.
_ = fs.WalkDir(s3fs, ".", func(path string, d fs.DirEntry, err error) error {
    if err != nil {
        return err
    }

    if d.IsDir() {
        fmt.Println("dir:", path)
        return nil
    }
    fmt.Println("file:", path)
    return nil
})

Installation

go get github.com/jszwec/s3fs

Requirements

  • Go1.16+

Documentation

Overview

Package s3fs provides a S3 implementation for Go1.16 filesystem interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type S3FS

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

S3FS is a S3 filesystem implementation.

S3 has a flat structure instead of a hierarchy. S3FS simulates directories by using prefixes and delims ("/"). Because directories are simulated, ModTime is always a default Time value (IsZero returns true).

func New

func New(cl s3iface.S3API, bucket string) *S3FS

New returns a new filesystem that works on the specified bucket.

func (*S3FS) MkdirAll added in v0.3.3

func (f *S3FS) MkdirAll(path string, perm os.FileMode) error

func (*S3FS) Open

func (f *S3FS) Open(name string) (fs.File, error)

Open implements fs.FS.

func (*S3FS) ReadDir

func (f *S3FS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir implements fs.ReadDirFS.

func (*S3FS) Rename added in v0.3.3

func (f *S3FS) Rename(oldpath, newpath string) error

func (*S3FS) Stat

func (f *S3FS) Stat(name string) (fs.FileInfo, error)

Stat implements fs.StatFS.

func (*S3FS) WriteFile added in v0.3.3

func (f *S3FS) WriteFile(filename string, data []byte, perm fs.FileMode) error

Jump to

Keyboard shortcuts

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