Documentation ¶
Index ¶
- func NewS3StaticCreds(accessID, secretKey string) *credentials.Credentials
- type FileBuffer
- func (f *FileBuffer) Bytes() []byte
- func (f *FileBuffer) Close() error
- func (f *FileBuffer) Read(b []byte) (n int, err error)
- func (f *FileBuffer) ReadAt(p []byte, off int64) (n int, err error)
- func (f *FileBuffer) Reopen() error
- func (f *FileBuffer) Reset() error
- func (f *FileBuffer) Seek(offset int64, whence int) (idx int64, err error)
- func (f *FileBuffer) String() string
- func (f *FileBuffer) Write(p []byte) (n int, err error)
- type FileSystemService
- func (s *FileSystemService) DeleteObject(ctx context.Context, path string) error
- func (s *FileSystemService) GetObject(ctx context.Context, path string) (*Object, error)
- func (s *FileSystemService) ListObjects(ctx context.Context, prefix string) ([]*Object, error)
- func (s *FileSystemService) PutObject(ctx context.Context, path string, content io.Reader) error
- type Object
- type S3Options
- type S3Service
- func (s *S3Service) DeleteObject(ctx context.Context, path string) error
- func (s *S3Service) GetObject(ctx context.Context, path string) (*Object, error)
- func (s *S3Service) ListObjects(ctx context.Context, prefix string) ([]*Object, error)
- func (s *S3Service) PutObject(ctx context.Context, path string, content io.Reader) error
- func (s *S3Service) SetACL(acl string) error
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewS3StaticCreds ¶
func NewS3StaticCreds(accessID, secretKey string) *credentials.Credentials
NewS3StaticCreds returns a simple static credentials object
Types ¶
type FileBuffer ¶
type FileBuffer struct { // Buff is the backing buffer Buff *bytes.Buffer // Index indicates where in the buffer we are at Index int64 // contains filtered or unexported fields }
FileBuffer implements interfaces implemented by files. The main purpose of this type is to have an in memory replacement for a file.
func NewFromReader ¶
func NewFromReader(reader io.Reader) (*FileBuffer, error)
NewFromReader is a convenience method that returns a new populated Buffer whose contents are sourced from a supplied reader by loading it entirely into memory.
func (*FileBuffer) Bytes ¶
func (f *FileBuffer) Bytes() []byte
Bytes returns the bytes available until the end of the buffer.
func (*FileBuffer) Close ¶
func (f *FileBuffer) Close() error
Close implements io.Closer https://golang.org/pkg/io/#Closer It closes the buffer, rendering it unusable for I/O. It returns an error, if any.
func (*FileBuffer) Read ¶
func (f *FileBuffer) Read(b []byte) (n int, err error)
When Read encounters an error or end-of-file condition after successfully reading n > 0 bytes, it returns the number of bytes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. An instance of this general case is that a Reader returning a non-zero number of bytes at the end of the input stream may return either err == EOF or err == nil. The next Read should return 0, EOF.
func (*FileBuffer) ReadAt ¶
func (f *FileBuffer) ReadAt(p []byte, off int64) (n int, err error)
ReadAt implements io.ReaderAt https://golang.org/pkg/io/#ReaderAt ReadAt reads len(p) bytes into p starting at offset off in the underlying input source. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.
When ReadAt returns n < len(p), it returns a non-nil error explaining why more bytes were not returned. In this respect, ReadAt is stricter than Read.
Even if ReadAt returns n < len(p), it may use all of p as scratch space during the call. If some data is available but not len(p) bytes, ReadAt blocks until either all the data is available or an error occurs. In this respect ReadAt is different from Read.
If the n = len(p) bytes returned by ReadAt are at the end of the input source, ReadAt may return either err == EOF or err == nil.
If ReadAt is reading from an input source with a seek offset, ReadAt should not affect nor be affected by the underlying seek offset. Clients of ReadAt can execute parallel ReadAt calls on the same input source.
func (*FileBuffer) Reopen ¶
func (f *FileBuffer) Reopen() error
Reopen is just a utility to reaccess the buffer after it's been closed.
func (*FileBuffer) Seek ¶
func (f *FileBuffer) Seek(offset int64, whence int) (idx int64, err error)
Seek implements io.Seeker https://golang.org/pkg/io/#Seeker
func (*FileBuffer) String ¶
func (f *FileBuffer) String() string
String implements the Stringer interface
func (*FileBuffer) Write ¶
func (f *FileBuffer) Write(p []byte) (n int, err error)
Write implements io.Writer https://golang.org/pkg/io/#Writer by appending the passed bytes to the buffer unless the buffer is closed or index negative.
type FileSystemService ¶
type FileSystemService struct {
RootDirectory string
}
FileSystemService is a storage backend for local filesystem storage
func NewFileSystemService ¶
func NewFileSystemService(rootDirectory string) *FileSystemService
NewFileSystemService creates a new instance of LocalFilesystemBackend
func (*FileSystemService) DeleteObject ¶
func (s *FileSystemService) DeleteObject(ctx context.Context, path string) error
DeleteObject removes an object from root directory
func (*FileSystemService) GetObject ¶
GetObject retrieves an object from root directory
func (*FileSystemService) ListObjects ¶
ListObjects lists all objects in root directory (depth 1)
type Object ¶
type Object struct { Path string Content io.ReadCloser ETag string ContentType string Size int64 LastModified time.Time }
Object is a generic representation of a storage object
func (*Object) HasExtension ¶
HasExtension determines whether or not an object contains a file extension
type S3Options ¶
type S3Options struct { Creds *credentials.Credentials Region string Prefix string Secure bool ACL string }
S3Options is a struct to hold service options
type S3Service ¶
type S3Service struct { Bucket string Client *minio.Client Prefix string // contains filtered or unexported fields }
S3Service is a storage backend for Amazon S3
func NewS3Service ¶
NewS3Service creates a new instance of S3Service
func (*S3Service) DeleteObject ¶
DeleteObject removes an object from Amazon S3 compat bucket, at prefix
func (*S3Service) GetObject ¶
GetObject retrieves an object from Amazon S3 compat bucket, at prefix
func (*S3Service) ListObjects ¶
ListObjects lists all objects in Amazon S3 compat bucket, at prefix
func (*S3Service) PutObject ¶
PutObject uploads an object to Amazon S3 compat bucket, at prefix
type Service ¶
type Service interface { ListObjects(ctx context.Context, prefix string) ([]*Object, error) GetObject(ctx context.Context, path string) (*Object, error) PutObject(ctx context.Context, path string, content io.Reader) error DeleteObject(ctx context.Context, path string) error }
Service is a generic interface for storage backends