Documentation ¶
Index ¶
- Variables
- func IsUnionPath(p string) bool
- type FileStat
- type Interface
- type OSStore
- func (s *OSStore) Delete(key string) (err error)
- func (s *OSStore) DeleteDirectory(dir string) (err error)
- func (s *OSStore) DownloadBytes(key string) ([]byte, error)
- func (s *OSStore) DownloadRangeBytes(key string, offset int64, size int64) ([]byte, error)
- func (s *OSStore) DownloadRangeReader(key string, offset int64, size int64) (io.ReadCloser, error)
- func (s *OSStore) DownloadReader(key string) (io.ReadCloser, error)
- func (s *OSStore) Exists(key string) (bool, error)
- func (s *OSStore) ListPrefix(key string) (keys []string, err error)
- func (s *OSStore) Stat(key string) (FileStat, error)
- func (s *OSStore) Upload(file string, key string) (err error)
- func (s *OSStore) UploadData(data []byte, key string) (err error)
- func (s *OSStore) UploadReader(reader io.Reader, _ int64, key string) (err error)
- type PathProtocol
- type QiniuStore
- func (s *QiniuStore) Delete(key string) (err error)
- func (s *QiniuStore) DeleteDirectory(dir string) (err error)
- func (s *QiniuStore) DownloadBytes(key string) ([]byte, error)
- func (s *QiniuStore) DownloadRangeBytes(key string, offset int64, size int64) ([]byte, error)
- func (s *QiniuStore) DownloadRangeReader(key string, offset int64, size int64) (io.ReadCloser, error)
- func (s *QiniuStore) DownloadReader(key string) (io.ReadCloser, error)
- func (s *QiniuStore) Exists(key string) (bool, error)
- func (s *QiniuStore) ListPrefix(key string) ([]string, error)
- func (s *QiniuStore) Stat(key string) (FileStat, error)
- func (s *QiniuStore) Upload(file string, key string) (err error)
- func (s *QiniuStore) UploadData(data []byte, key string) (err error)
- func (s *QiniuStore) UploadReader(reader io.Reader, _ int64, key string) (err error)
- type Reader
- type S3Config
- type S3Store
- func (s *S3Store) Delete(key string) (err error)
- func (s *S3Store) DeleteDirectory(dir string) (err error)
- func (s *S3Store) DownloadBytes(key string) ([]byte, error)
- func (s *S3Store) DownloadRangeBytes(key string, offset int64, size int64) ([]byte, error)
- func (s *S3Store) DownloadRangeReader(key string, offset int64, size int64) (io.ReadCloser, error)
- func (s *S3Store) DownloadReader(key string) (io.ReadCloser, error)
- func (s *S3Store) Exists(key string) (bool, error)
- func (s *S3Store) ListPrefix(key string) (keys []string, err error)
- func (s *S3Store) Stat(key string) (FileStat, error)
- func (s *S3Store) Upload(file string, key string) (err error)
- func (s *S3Store) UploadData(data []byte, key string) (err error)
- func (s *S3Store) UploadReader(reader io.Reader, size int64, key string) (err error)
- type Store
- func (s *Store) Delete(key string) (err error)
- func (s *Store) DeleteDirectory(dir string) (err error)
- func (s *Store) DownloadBytes(key string) (data []byte, err error)
- func (s *Store) DownloadRangeBytes(key string, offset int64, size int64) (data []byte, err error)
- func (s *Store) DownloadRangeReader(key string, offset int64, size int64) (rc io.ReadCloser, err error)
- func (s *Store) DownloadReader(key string) (rc io.ReadCloser, err error)
- func (s *Store) Exists(key string) (e bool, err error)
- func (s *Store) ListPrefix(key string) ([]string, error)
- func (s *Store) Stat(key string) (fs FileStat, err error)
- func (s *Store) Upload(file string, key string) (err error)
- func (s *Store) UploadData(data []byte, key string) (err error)
- func (s *Store) UploadReader(reader io.Reader, size int64, key string) (err error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotConfigured = fmt.Errorf("store is not configured") S3Env = "S3_STORE_CONFIG" S3ReaderEnv = "S3_READER_CONFIG" QiniuEnv = "QINIU_STORE_CONFIG" QiniuReaderEnv = "QINIU_READER_CONFIG" )
var (
QiniuNotConfigError = fmt.Errorf("qiniu is not configured")
)
var (
S3NotConfigError = fmt.Errorf("s3 store is not configured")
)
Functions ¶
func IsUnionPath ¶ added in v0.0.3
Types ¶
type Interface ¶
type Interface interface { Stat(key string) (FileStat, error) UploadData(data []byte, key string) (err error) Upload(file string, key string) (err error) UploadReader(reader io.Reader, size int64, key string) (err error) DeleteDirectory(dir string) (err error) Delete(key string) (err error) Exists(key string) (bool, error) DownloadBytes(key string) ([]byte, error) DownloadReader(key string) (io.ReadCloser, error) DownloadRangeBytes(key string, offset int64, size int64) ([]byte, error) DownloadRangeReader(key string, offset int64, size int64) (io.ReadCloser, error) ListPrefix(key string) ([]string, error) }
func NewMultiClusterQiniuStore ¶ added in v0.1.2
NewMultiClusterQiniuStore initializes a multi-cluster qiniu store, only support QINIU_MULTI_CLUSTER environment variable
func NewOSStore ¶
func NewOSStore() Interface
func NewQiniuStore ¶
func NewS3Store ¶
type OSStore ¶
type OSStore struct { }
func (*OSStore) DeleteDirectory ¶
DeleteDirectory deletes a directory and all of its contents. If the directory is empty, return nil.
func (*OSStore) DownloadRangeBytes ¶
func (*OSStore) DownloadRangeReader ¶
func (*OSStore) DownloadReader ¶
func (s *OSStore) DownloadReader(key string) (io.ReadCloser, error)
func (*OSStore) UploadData ¶
UploadData writes data to the given file. If the file already exists, it will return an error.
type PathProtocol ¶
type PathProtocol string
const ( // QiniuProtocol is the protocol of Qiniu. // A file path should start with "qiniu://" or "qiniu:". // 1. qiniu://{host}/file/path // 2. qiniu:/file/path // Check https://en.wikipedia.org/wiki/File_URI_scheme QiniuProtocol PathProtocol = "qiniu" S3Protocol PathProtocol = "s3" OSProtocol PathProtocol = "" UnknownProtocol PathProtocol = "Unknown" )
func GetPathProtocol ¶
func GetPathProtocol(p string) (PathProtocol, string, error)
func (PathProtocol) String ¶
func (p PathProtocol) String() string
type QiniuStore ¶
type QiniuStore struct {
// contains filtered or unexported fields
}
func (*QiniuStore) Delete ¶
func (s *QiniuStore) Delete(key string) (err error)
Delete deletes a file from the Qiniu store.
func (*QiniuStore) DeleteDirectory ¶
func (s *QiniuStore) DeleteDirectory(dir string) (err error)
DeleteDirectory deletes a directory from the Qiniu store.
func (*QiniuStore) DownloadBytes ¶
func (s *QiniuStore) DownloadBytes(key string) ([]byte, error)
func (*QiniuStore) DownloadRangeBytes ¶
func (*QiniuStore) DownloadRangeReader ¶
func (s *QiniuStore) DownloadRangeReader(key string, offset int64, size int64) (io.ReadCloser, error)
func (*QiniuStore) DownloadReader ¶
func (s *QiniuStore) DownloadReader(key string) (io.ReadCloser, error)
func (*QiniuStore) Exists ¶
func (s *QiniuStore) Exists(key string) (bool, error)
Exists returns true if the key exists in the Qiniu store.
func (*QiniuStore) ListPrefix ¶
func (s *QiniuStore) ListPrefix(key string) ([]string, error)
func (*QiniuStore) Stat ¶
func (s *QiniuStore) Stat(key string) (FileStat, error)
Stat returns the FileInfo for the named file.
func (*QiniuStore) Upload ¶
func (s *QiniuStore) Upload(file string, key string) (err error)
Upload uploads a file to qiniu.
func (*QiniuStore) UploadData ¶
func (s *QiniuStore) UploadData(data []byte, key string) (err error)
UploadData upload memory data to Qiniu store.
func (*QiniuStore) UploadReader ¶
UploadReader upload reader to the Qiniu store.
type Reader ¶ added in v0.0.2
type Reader struct { Key string Offset *int64 Size *int64 // contains filtered or unexported fields }
type S3Config ¶
type S3Config struct { Endpoint string `json:"endpoint" yaml:"endpoint" toml:"endpoint"` Region string `json:"region" yaml:"region" toml:"region"` Bucket string `json:"bucket" yaml:"bucket" toml:"bucket"` AccessKey string `json:"access_key" yaml:"access_key" toml:"access_key"` SecretKey string `json:"secret_key" yaml:"secret_key" toml:"secret_key"` Token string `json:"token" yaml:"token" toml:"token"` UseSSL bool `json:"use_ssl" yaml:"use_ssl" toml:"use_ssl"` }
func LoadS3Config ¶
type S3Store ¶
type S3Store struct {
// contains filtered or unexported fields
}
func (*S3Store) Delete ¶
Delete deletes the object. This is soft-delete operation, file will be renamed to recyclePath.
func (*S3Store) DeleteDirectory ¶
DeleteDirectory removes the directory from the s3 store. This is a soft-delete operation, all files will be renamed to .
func (*S3Store) DownloadRangeBytes ¶
func (*S3Store) DownloadRangeReader ¶
func (*S3Store) DownloadReader ¶
func (s *S3Store) DownloadReader(key string) (io.ReadCloser, error)
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) DeleteDirectory ¶
func (*Store) DownloadRangeBytes ¶
func (*Store) DownloadRangeReader ¶
func (*Store) DownloadReader ¶
func (s *Store) DownloadReader(key string) (rc io.ReadCloser, err error)