aferoS3

package module
v0.0.0-...-0cf1f62 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

afero-s3

Afero S3 is a Afero FS interface for Amazon s3

Install

go get github.com/spf13/afero
go get github.com/chonthu/aferoS3

How to use

// import afero, aferos3, and the aws sdk
import (
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/chonthu/aferos3"
)

sess := session.Must(session.NewSession(&aws.Config{
	Region: aws.String("us-east-1")
}))

S3Fs, err := aferoS3.NewS3Fs(sess,"bucket_name")
if err != nil {
	fmt.Println(err)
	return
}

file, err := S3Fs.Open("path/to/file.jpg")

if err != nil {
	fmt.Println(err)
	return
}

License

This project uses the https://github.com/aws/aws-sdk-go, thanks amazon web services for the great library

This SDK is distributed under the Apache License, Version 2.0, see LICENSE.txt and NOTICE.txt for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type S3FileInfo

type S3FileInfo struct {
	os.FileInfo
	// contains filtered or unexported fields
}

S3FileInfo info

type S3Fs

type S3Fs struct {
	Bucket string
	// contains filtered or unexported fields
}

S3Fs main struct

func NewS3Fs

func NewS3Fs(sess *session.Session, bucketName string) *S3Fs

NewS3Fs create a new instance

func (S3Fs) Chmod

func (s S3Fs) Chmod(name string, mode os.FileMode) error

Chmod not implemented

func (S3Fs) Chtimes

func (S3Fs) Chtimes(name string, atime time.Time, mtime time.Time) error

Chtimes not implemented

func (S3Fs) Create

func (S3Fs) Create(name string) (afero.File, error)

Create a new file in memory, doesnt persits until pushing to s3

func (*S3Fs) CreateBucket

func (s *S3Fs) CreateBucket(name string) error

CreateBucket create a s3 bucket

func (S3Fs) Exists

func (s S3Fs) Exists(path string) (bool, error)

Exists checks if object exsists

func (S3Fs) IsDir

func (s S3Fs) IsDir(path string) (bool, error)

IsDir check if this is a valid directory

func (S3Fs) Mkdir

func (S3Fs) Mkdir(name string, perm os.FileMode) error

Mkdir Dont think we can do much here

func (S3Fs) MkdirAll

func (S3Fs) MkdirAll(path string, perm os.FileMode) error

MkdirAll Dont think we can do much here

func (S3Fs) Name

func (S3Fs) Name() string

Name the name of the module

func (S3Fs) Open

func (s S3Fs) Open(name string) (afero.File, error)

Open from s3, and bring down whole file

func (S3Fs) OpenFile

func (s S3Fs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

OpenFile different between Open is its torrent, and this is the actuall file

func (S3Fs) Push

func (s S3Fs) Push(f afero.File, path string) error

Push object to s3

func (S3Fs) ReadDir

func (s S3Fs) ReadDir(dirname string) ([]string, error)

ReadDir reads a current file and returns contents

func (S3Fs) Remove

func (s S3Fs) Remove(name string) error

Remove a file

func (S3Fs) RemoveAll

func (s S3Fs) RemoveAll(dirname string) error

RemoveAll removes all files

func (S3Fs) Rename

func (s S3Fs) Rename(oldname, newname string) error

Rename a file

func (S3Fs) Stat

func (s S3Fs) Stat(name string) (os.FileInfo, error)

Stat get s3 stats

Jump to

Keyboard shortcuts

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