fsstorage

package
v0.0.0-...-4cce589 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package fsstorage is an implementation of filestorage using the filesystem

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Creator

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

Creator creates new filestorage

func NewCreator

func NewCreator(defaultBucket string) *Creator

NewCreator returns a filestorage creator that will use the provided keys to create a new cloudinary driver for each single logger

func (*Creator) New

func (c *Creator) New() (filestorage.FileStorage, error)

New returns a new fs client

func (*Creator) NewWithContext

func (c *Creator) NewWithContext(ctx context.Context) (filestorage.FileStorage, error)

NewWithContext returns a new gc storage client using the provided context as default context

type FSStorage

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

FSStorage is an implementation of the FileStorage interface for the file system

func New

func New() (*FSStorage, error)

New returns a new instance of a File System Storage

func NewWithContext

func NewWithContext(ctx context.Context, path string) (*FSStorage, error)

NewWithContext returns a new GCStorage instance using a new Google Cloud Storage client attached to the provided context

func NewWithDir

func NewWithDir(path string) (*FSStorage, error)

NewWithDir returns a new instance of a File System Storage with

func (*FSStorage) Attributes

func (s *FSStorage) Attributes(filepath string) (*filestorage.FileAttributes, error)

Attributes returns the attributes of the file Will use the defaut context

func (*FSStorage) AttributesCtx

func (s *FSStorage) AttributesCtx(ctx context.Context, filepath string) (*filestorage.FileAttributes, error)

AttributesCtx returns the attributes of the file

func (*FSStorage) Delete

func (s *FSStorage) Delete(filepath string) error

Delete removes a file, ignores files that do not exist Will use the defaut context

func (*FSStorage) DeleteCtx

func (s *FSStorage) DeleteCtx(ctx context.Context, filepath string) error

DeleteCtx removes a file, ignores files that do not exist

func (*FSStorage) Exists

func (s *FSStorage) Exists(filepath string) (bool, error)

Exists check if a file exists Will use the defaut context

func (*FSStorage) ExistsCtx

func (s *FSStorage) ExistsCtx(ctx context.Context, filepath string) (bool, error)

ExistsCtx check if a file exists

func (*FSStorage) ID

func (s *FSStorage) ID() string

ID returns the unique identifier of the storage provider

func (*FSStorage) Read

func (s *FSStorage) Read(filepath string) (io.ReadCloser, error)

Read fetches a file a returns a reader Will use the defaut context

func (*FSStorage) ReadCtx

func (s *FSStorage) ReadCtx(ctx context.Context, filepath string) (io.ReadCloser, error)

ReadCtx fetches a file a returns a reader

func (*FSStorage) SetAttributes

func (s *FSStorage) SetAttributes(filepath string, attrs *filestorage.UpdatableFileAttributes) (*filestorage.FileAttributes, error)

SetAttributes sets the attributes of the file Will use the defaut context

func (*FSStorage) SetAttributesCtx

func (s *FSStorage) SetAttributesCtx(ctx context.Context, filepath string, attrs *filestorage.UpdatableFileAttributes) (*filestorage.FileAttributes, error)

SetAttributesCtx sets the attributes of the file

func (*FSStorage) SetBucket

func (s *FSStorage) SetBucket(name string) error

SetBucket is used to set the bucket

func (*FSStorage) URL

func (s *FSStorage) URL(filepath string) (string, error)

URL returns the URL of the file Will use the defaut context

func (*FSStorage) URLCtx

func (s *FSStorage) URLCtx(ctx context.Context, filepath string) (string, error)

URLCtx returns the URL of the file

func (*FSStorage) Write

func (s *FSStorage) Write(src io.Reader, destPath string) error

Write copy the provided os.File to dest Will use the defaut context

func (*FSStorage) WriteCtx

func (s *FSStorage) WriteCtx(ctx context.Context, src io.Reader, destPath string) error

WriteCtx copy the provided os.File to dest

func (*FSStorage) WriteIfNotExist

func (s *FSStorage) WriteIfNotExist(src io.Reader, destPath string) (new bool, url string, err error)

WriteIfNotExist copies the provided io.Reader to dest if the file does not already exist Returns:

  • A boolean specifying if the file got uploaded (true) or if already existed (false).
  • A URL to the uploaded file
  • An error if something went wrong

Will use the defaut context

func (*FSStorage) WriteIfNotExistCtx

func (s *FSStorage) WriteIfNotExistCtx(ctx context.Context, src io.Reader, destPath string) (new bool, url string, err error)

WriteIfNotExistCtx copies the provided io.Reader to dest if the file does not already exist Returns:

  • A boolean specifying if the file got uploaded (true) or if already existed (false).
  • A URL to the uploaded file
  • An error if something went wrong

Jump to

Keyboard shortcuts

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