Documentation
¶
Index ¶
- type LocalStorageSignedURLBuilder
- type ObjectVisibility
- type Storage
- func NewAWSS3Storage(bucketName string, region string, accessKeyID string, secretAccessKey string, ...) Storage
- func NewAlibabaOSSStorage(bucketName string, endpoint string, accessID string, accessSecret string) Storage
- func NewLocalStorage(baseDir string, publicBaseDir string, publicBaseURL string, ...) Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LocalStorageSignedURLBuilder ¶
type LocalStorageSignedURLBuilder func(absoluteFilePath string, objectPath string, expireIn time.Duration) (string, error)
LocalStorageSignedURLBuilder is used to serve file temporarily in private directory mode
type ObjectVisibility ¶
type ObjectVisibility string
const ( ObjectPrivate ObjectVisibility = "private" ObjectPublicReadWrite ObjectVisibility = "public-read-write" ObjectPublicRead ObjectVisibility = "public-read" )
type Storage ¶
type Storage interface {
// Read return reader to stream data from source
Read(objectPath string) (io.ReadCloser, error)
// Put store source stream into
Put(objectPath string, source io.Reader, visibility ObjectVisibility) error
// Delete object by objectPath
Delete(objectPaths ...string) error
// URL return object url
URL(objectPath string) (string, error)
// TemporaryURL give temporary access to an object using returned signed url
TemporaryURL(objectPath string, expireIn time.Duration) (string, error)
// Copy source to destination
Copy(srcObjectPath string, dstObjectPath string) error
// Size return object size
Size(objectPath string) (int64, error)
// LastModified return last modified time of object
LastModified(objectPath string) (time.Time, error)
// Exist check whether object exists
Exist(objectPath string) (bool, error)
// SetVisibility update object visibility for a given object path
SetVisibility(objectPath string, visibility ObjectVisibility) error
// GetVisibility return object visibility for a given object path
GetVisibility(objectPath string) (ObjectVisibility, error)
}
Storage is an abstraction for persistence storage mechanism, remember that all object path used here should be specified relative to the root location configured for each implementation
func NewAWSS3Storage ¶
func NewAWSS3Storage( bucketName string, region string, accessKeyID string, secretAccessKey string, sessionToken string) Storage
NewAWSS3Storage create new storage backed by AWS S3
func NewAlibabaOSSStorage ¶
func NewAlibabaOSSStorage( bucketName string, endpoint string, accessID string, accessSecret string) Storage
NewAlibabaOSSStorage create storage backed by alibaba oss
func NewLocalStorage ¶
func NewLocalStorage( baseDir string, publicBaseDir string, publicBaseURL string, signedURLBuilder LocalStorageSignedURLBuilder) Storage
NewLocalStorage create local file storage with given params baseDir: base directory where a private file is stored (conventionally directory should not publicly serve over http) publicBaseDir: base directory where a public file reside, the file actually a link from baseDir, directory should be publicly serve over http publicBaseURL: base URL where to be concatenated with objectPath to build full file download URL signedURLBuilder: used to generate temporary download URL for serving private files if needed (provide nil will always return error)