Documentation ¶
Overview ¶
Package filestorage describes interfaces to deal with filestorage
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Creator ¶
type Creator interface { New() (FileStorage, error) NewWithContext(ctx context.Context) (FileStorage, error) }
Creator creates new FileStorage
type FileAttributes ¶
type FileAttributes struct { ContentType string ContentLanguage string ContentEncoding string ContentDisposition string CacheControl string Metadata map[string]string }
FileAttributes represents the attributes a file can have
func NewFileAttributesFromUpdatable ¶
func NewFileAttributesFromUpdatable(attrs *UpdatableFileAttributes) *FileAttributes
NewFileAttributesFromUpdatable returns a FileAttributes from a UpdatableFileAttributes
type FileStorage ¶
type FileStorage interface { // ID returns the unique identifier of the storage provider ID() string // SetBucket sets the bucket that will contains the files SetBucket(bucket string) error // Read fetches a file a returns a reader // Returns os.ErrNotExist if the file does not exists // Will use the defaut context Read(filepath string) (io.ReadCloser, error) // ReadCtx fetches a file a returns a reader // Returns os.ErrNotExist if the file does not exists ReadCtx(ctx context.Context, filepath string) (io.ReadCloser, error) // Write copies the provided io.Reader to dest // Will use the defaut context Write(src io.Reader, destPath string) error // WriteCtx copies the provided io.Reader to dest WriteCtx(ctx context.Context, src io.Reader, destPath string) error // Delete removes a file, ignores files that do not exist // Will use the defaut context Delete(filepath string) error // DeleteCtx removes a file, ignores files that do not exist DeleteCtx(ctx context.Context, filepath string) error // URL returns the URL of the file // Will use the defaut context URL(filepath string) (string, error) // URLCtx returns the URL of the file URLCtx(ctx context.Context, filepath string) (string, error) // SetAttributes sets the attributes of the file // Will use the defaut context SetAttributes(filepath string, attrs *UpdatableFileAttributes) (*FileAttributes, error) // SetAttributesCtx sets the attributes of the file SetAttributesCtx(ctx context.Context, filepath string, attrs *UpdatableFileAttributes) (*FileAttributes, error) // Attributes returns the attributes of the file // Will use the defaut context Attributes(filepath string) (*FileAttributes, error) // AttributesCtx returns the attributes of the file AttributesCtx(ctx context.Context, filepath string) (*FileAttributes, error) // Exists check if a file exists // Will use the defaut context Exists(filepath string) (bool, error) // ExistsCtx check if a file exists ExistsCtx(ctx context.Context, filepath string) (bool, 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 WriteIfNotExist(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 WriteIfNotExistCtx(ctx context.Context, src io.Reader, destPath string) (new bool, url string, err error) }
FileStorage is a interface to store and retrieve files
type UpdatableFileAttributes ¶
type UpdatableFileAttributes struct { ContentType interface{} ContentLanguage interface{} ContentEncoding interface{} ContentDisposition interface{} CacheControl interface{} Metadata map[string]string // set to map[string]string{} to delete }
UpdatableFileAttributes represents the updatable attributes a file can have
Directories ¶
Path | Synopsis |
---|---|
Package implementations contains helpers to help implementing a filestorage
|
Package implementations contains helpers to help implementing a filestorage |
cloudinary
Package cloudinary is an implementation of filestorage for Cloudinary
|
Package cloudinary is an implementation of filestorage for Cloudinary |
fsstorage
Package fsstorage is an implementation of filestorage using the filesystem
|
Package fsstorage is an implementation of filestorage using the filesystem |
gcstorage
Package gcstorage is an implementation of filestorage for Google Cloud
|
Package gcstorage is an implementation of filestorage for Google Cloud |
mockfilestorage
Package mockfilestorage is a generated GoMock package.
|
Package mockfilestorage is a generated GoMock package. |
Package testfilestorage contains helpers to help testing a filestorage implementation
|
Package testfilestorage contains helpers to help testing a filestorage implementation |
Click to show internal directories.
Click to hide internal directories.