Documentation
¶
Index ¶
- func CombineUri(uri string, parts ...string) string
- func GetUriPath(uri string) (path string, err error)
- func ParseUri(uri string) (schema, path, file, ext string, err error)
- type HttpFile
- func (f *HttpFile) Close() error
- func (f *HttpFile) Copy(wc io.WriteCloser) (int64, error)
- func (f *HttpFile) Delete() error
- func (f *HttpFile) Exists() (result bool)
- func (f *HttpFile) Read(p []byte) (int, error)
- func (f *HttpFile) ReadAll() ([]byte, error)
- func (f *HttpFile) Rename(pattern string) (string, error)
- func (f *HttpFile) URI() string
- func (f *HttpFile) Write(p []byte) (int, error)
- func (f *HttpFile) WriteAll(b []byte) (int, error)
- type HttpFileStore
- type IFile
- type IFileStore
- type LocalFile
- func (f *LocalFile) Close() error
- func (f *LocalFile) Copy(wc io.WriteCloser) (int64, error)
- func (f *LocalFile) Delete() error
- func (f *LocalFile) Exists() (result bool)
- func (f *LocalFile) Read(p []byte) (int, error)
- func (f *LocalFile) ReadAll() ([]byte, error)
- func (f *LocalFile) Rename(pattern string) (string, error)
- func (f *LocalFile) URI() string
- func (f *LocalFile) Write(p []byte) (int, error)
- func (f *LocalFile) WriteAll(b []byte) (int, error)
- type LocalFileStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombineUri ¶
CombineUri creates a URI from segments
func GetUriPath ¶
GetUriPath extract path from the uri
Types ¶
type HttpFile ¶
type HttpFile struct {
// contains filtered or unexported fields
}
HttpFile is a concrete http implementation of IFile interface
func (*HttpFile) Copy ¶
func (f *HttpFile) Copy(wc io.WriteCloser) (int64, error)
Copy file content to a writer
func (*HttpFile) Rename ¶
Rename change the resource name using pattern. The pattern can be a file or keeping parts from the original file using template ({{path}}, {{file}}, {{ext}})
type HttpFileStore ¶
type HttpFileStore struct {
// contains filtered or unexported fields
}
HttpFileStore is a concrete implementation of FileStore interface
func (*HttpFileStore) Apply ¶
func (f *HttpFileStore) Apply(filter string, action func(string)) error
Apply action on files in the file store
func (*HttpFileStore) Delete ¶
func (f *HttpFileStore) Delete(uri string) (err error)
Delete resource
func (*HttpFileStore) Exists ¶
func (f *HttpFileStore) Exists(uri string) (result bool)
Exists test for resource existence
func (*HttpFileStore) List ¶
func (f *HttpFileStore) List(filter string) ([]IFile, error)
List files in the file store
func (*HttpFileStore) URI ¶
func (f *HttpFileStore) URI() string
URI returns the resource URI with schema
type IFile ¶
type IFile interface {
// ReadWriteCloser must implement Read(), Write() and Close() method
io.ReadWriteCloser
// URI returns the resource URI with schema
// Schema can be: file, gcs, http etc
URI() string
// Exists test for resource existence
Exists() (result bool)
// Rename change the resource name using pattern.
// The pattern can be an absolute name or keeping parts from the original file using template (path, name, ext)
Rename(pattern string) (result string, err error)
// Delete resource
Delete() (err error)
// ReadAll read resource content to a byte array in a single call
ReadAll() (b []byte, err error)
// WriteAll write content to a resource in a single call
WriteAll(b []byte) (n int, err error)
// Copy file content to a writer
Copy(wc io.WriteCloser) (written int64, err error)
}
IFile File interface This interface is used for concrete implementation of any file (local file system, HTTP files, Google / AWS Buckets etc).
type IFileStore ¶
type IFileStore interface {
// URI returns the resource URI with schema
// Schema can be: file, gcs, http etc
URI() string
// List files in the URI using regexp filter
List(filter string) (result []IFile, err error)
// Apply action on files in the file store
Apply(filter string, action func(string)) error
// Exists test for resource existence
Exists(uri string) (result bool)
// Delete resource
Delete(uri string) (err error)
}
IFileStore Files store interface This interface is used for concrete implementation of any file store (local file system, HTTP files, Google / AWS Buckets etc.
func NewHttpFileStore ¶
func NewHttpFileStore(uri string) IFileStore
NewHttpFileStore factory method
func NewLocalFileStore ¶
func NewLocalFileStore(uri string) IFileStore
NewLocalFileStore factory method
type LocalFile ¶
type LocalFile struct {
// contains filtered or unexported fields
}
LocalFile is a concrete file system implementation of IFile interface
func (*LocalFile) Copy ¶
func (f *LocalFile) Copy(wc io.WriteCloser) (int64, error)
Copy file content to a writer
func (*LocalFile) Rename ¶
Rename change the resource name using pattern. The pattern can be a file or keeping parts from the original file using template ({{path}}, {{file}}, {{ext}})
type LocalFileStore ¶
type LocalFileStore struct {
// contains filtered or unexported fields
}
LocalFileStore is a concrete implementation of FileStore interface
func (*LocalFileStore) Apply ¶
func (f *LocalFileStore) Apply(filter string, action func(string)) error
Apply action on files in the file store
func (*LocalFileStore) Delete ¶
func (f *LocalFileStore) Delete(uri string) (err error)
Delete resource
func (*LocalFileStore) Exists ¶
func (f *LocalFileStore) Exists(uri string) (result bool)
Exists test for resource existence
func (*LocalFileStore) List ¶
func (f *LocalFileStore) List(filter string) ([]IFile, error)
List files in the file store
func (*LocalFileStore) URI ¶
func (f *LocalFileStore) URI() string
URI returns the resource URI with schema Schema can be: file, gcs, http etc