Documentation ¶
Index ¶
- Constants
- Variables
- func NewAWSConfigWithStaticCredentials(awsAccessKey, awsSecretKey string) *aws.Config
- func NewAWSConfigWithStaticCredentialsAndRegion(awsAccessKey, awsSecretKey, awsRegion string) *aws.Config
- func NewAWSSession() *session.Session
- func StringPtr(v string) *string
- type Client
- func (c *Client) Delete(path string) error
- func (c *Client) DeleteAll(pathPrefix string) error
- func (c *Client) GenerateURLWithExpire(path string, expire time.Duration) (string, error)
- func (c *Client) ListAll(pathPrefix string) ([]ListItem, error)
- func (c *Client) Read(path string) (*File, error)
- func (c *Client) Write(file *File) error
- type ClientOptions
- type DownloadOptions
- type File
- type ListItem
- type UploadOptions
Constants ¶
const ( S3ACLPrivate = "private" S3ACLPublicRead = "public-read" S3ACLPublicReadWrite = "public-read-write" S3ACLAuthenticatedRead = "authenticated-read" S3ACLAWSExecRead = "aws-exec-read" S3ACLBucketOwnerRead = "bucket-owner-read" S3ACLBucketOwnerFullControl = "bucket-owner-full-control" )
const ( S3StorageClassStandard = "STANDARD" S3StorageClassReducedRedundancy = "REDUCED_REDUNDANCY" S3StorageClassStandardIA = "STANDARD_IA" )
const ( S3EncryptionAES256 = "AES256" S3EncryptionAWSKMS = "aws:kms" )
Variables ¶
var (
ErrFileNotFound = errors.New("file not found")
)
Functions ¶
func NewAWSConfigWithStaticCredentials ¶
NewAWSConfigWithStaticCredentials returns AWS config with static credentials.
func NewAWSConfigWithStaticCredentialsAndRegion ¶
func NewAWSConfigWithStaticCredentialsAndRegion(awsAccessKey, awsSecretKey, awsRegion string) *aws.Config
NewAWSConfigWithStaticCredentialsAndRegion returns AWS config with static credentials and region.
func NewAWSSession ¶
NewAWSSession returns a default AWS session.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(bucket string, clientOptions *ClientOptions, awsSession client.ConfigProvider, awsConfigs ...*aws.Config) *Client
NewClient returns a new file store client.
func (*Client) Delete ¶
Delete deletes a file in path. Because the way S3 handles deletion (adding delete-marker for versioning), this function does not return any errors when the file does not exist.
func (*Client) GenerateURLWithExpire ¶
GenerateURLWithExpire creates a direct link (URL) for the file. Anyone with this link will be able to access the file (through HTTP GET) regardless of S3 bucket permission settings. The link created with this function will return a permission error after it expires.
func (*Client) ListAll ¶
ListAll returns all files and directories that has pathPrefix as path prefix.
type ClientOptions ¶
type ClientOptions struct { UploadOptions *UploadOptions DownloadOptions *DownloadOptions }
type DownloadOptions ¶
type File ¶
type File struct { // File path in the storage. Path string // File data. Data []byte // A map of metadata to store with the file in S3. // This is optional. Metadata map[string]string // Standard MIME type describing the format of the file data. // This is optional, and, will be set to "binary/octet-stream" by default. ContentType *string // Canned ACL to apply to the file. // Possible values include // - "private" // - "public-read" // - "public-read-write" // - "authenticated-read" // - "aws-exec-read" // - "bucket-owner-read" // - "bucket-owner-full-control" // This is optional. ACL *string // Server-side encryption algorithm used when storing file. // Possible values include "AES256", "aws:kms". // This is optional. Encryption *string // Type of storage to use for the file. // Possible values include "STANDARD", "REDUCED_REDUNDANCY", "STANDARD_IA". // This is optional, and, will be set to "STANDARD" by default. StorageClass *string }
File represents a file stored in S3 bucket.