Documentation ¶
Index ¶
- Constants
- Variables
- type BaseStorage
- type ContentFile
- type File
- type FileSystemFile
- type FileSystemStorage
- func (s *FileSystemStorage) AccessedTime(filepath string) (time.Time, error)
- func (s *FileSystemStorage) CreatedTime(filepath string) (time.Time, error)
- func (s *FileSystemStorage) Delete(filepath string) error
- func (s *FileSystemStorage) Exists(filepath string) bool
- func (s *FileSystemStorage) ModifiedTime(filepath string) (time.Time, error)
- func (s *FileSystemStorage) Open(filepath string) (File, error)
- func (s *FileSystemStorage) Save(filepath string, file File) error
- func (s *FileSystemStorage) SaveWithPermissions(filepath string, file File, perm os.FileMode) error
- func (s *FileSystemStorage) Size(filepath string) int64
- func (s *FileSystemStorage) URL(filename string) string
- type S3Storage
- func (s *S3Storage) Auth() (auth aws.Auth, err error)
- func (s *S3Storage) Bucket() (*s3.Bucket, error)
- func (s *S3Storage) Client() (*s3.S3, error)
- func (s *S3Storage) Delete(filepath string) error
- func (s *S3Storage) Exists(filepath string) bool
- func (s *S3Storage) Key(filepath string) (*s3.Key, error)
- func (s *S3Storage) ModifiedTime(filepath string) (time.Time, error)
- func (s *S3Storage) Open(filepath string) (File, error)
- func (s *S3Storage) Save(filepath string, file File) error
- func (s *S3Storage) SaveWithContentType(filepath string, file File, contentType string) error
- func (s *S3Storage) Size(filepath string) int64
- type S3StorageFile
- type Storage
Constants ¶
View Source
const LastModifiedFormat = time.RFC1123
Variables ¶
View Source
var ACLs = map[string]s3.ACL{ "private": s3.Private, "public-read": s3.PublicRead, "public-read-write": s3.PublicReadWrite, "authenticated-read": s3.AuthenticatedRead, "bucket-owner-read": s3.BucketOwnerRead, "bucket-owner-full-control": s3.BucketOwnerFull, }
View Source
var DefaultFilePermissions os.FileMode = 0755
Functions ¶
This section is empty.
Types ¶
type BaseStorage ¶
func NewBaseStorage ¶
func NewBaseStorage(location string, baseURL string) *BaseStorage
func (*BaseStorage) HasBaseURL ¶
func (s *BaseStorage) HasBaseURL() bool
func (*BaseStorage) Path ¶
func (s *BaseStorage) Path(filepath string) string
Path joins the given file to the storage path
func (*BaseStorage) URL ¶
func (s *BaseStorage) URL(filename string) string
type ContentFile ¶
func NewContentFile ¶
func NewContentFile(content []byte) *ContentFile
func (*ContentFile) Close ¶
func (f *ContentFile) Close() error
func (*ContentFile) ReadAll ¶
func (f *ContentFile) ReadAll() ([]byte, error)
func (*ContentFile) Size ¶
func (f *ContentFile) Size() int64
type FileSystemFile ¶
func NewFileSystemFile ¶
func NewFileSystemFile(storage Storage, file *os.File) (*FileSystemFile, error)
func (*FileSystemFile) ReadAll ¶
func (f *FileSystemFile) ReadAll() ([]byte, error)
func (*FileSystemFile) Size ¶
func (f *FileSystemFile) Size() int64
type FileSystemStorage ¶
type FileSystemStorage struct {
*BaseStorage
}
Storage is a file system storage handler
func (*FileSystemStorage) AccessedTime ¶
func (s *FileSystemStorage) AccessedTime(filepath string) (time.Time, error)
func (*FileSystemStorage) CreatedTime ¶
func (s *FileSystemStorage) CreatedTime(filepath string) (time.Time, error)
CreatedTime returns the last access time.
func (*FileSystemStorage) Delete ¶
func (s *FileSystemStorage) Delete(filepath string) error
Delete the file from storage
func (*FileSystemStorage) Exists ¶
func (s *FileSystemStorage) Exists(filepath string) bool
Exists checks if the given file is in the storage
func (*FileSystemStorage) ModifiedTime ¶
func (s *FileSystemStorage) ModifiedTime(filepath string) (time.Time, error)
ModifiedTime returns the last update time
func (*FileSystemStorage) Open ¶
func (s *FileSystemStorage) Open(filepath string) (File, error)
Open returns the file content
func (*FileSystemStorage) Save ¶
func (s *FileSystemStorage) Save(filepath string, file File) error
Save saves a file at the given path
func (*FileSystemStorage) SaveWithPermissions ¶
SaveWithPermissions saves a file with the given permissions to the storage
func (*FileSystemStorage) Size ¶
func (s *FileSystemStorage) Size(filepath string) int64
Size returns the size of the given file
func (*FileSystemStorage) URL ¶
func (s *FileSystemStorage) URL(filename string) string
type S3Storage ¶
type S3Storage struct { *BaseStorage AccessKeyId string SecretAccessKey string BucketName string Region aws.Region ACL s3.ACL }
func (*S3Storage) ModifiedTime ¶
ModifiedTime returns the last update time
func (*S3Storage) SaveWithContentType ¶
Save saves a file at the given path in the bucket
type S3StorageFile ¶
type S3StorageFile struct { io.ReadCloser Key *s3.Key Storage Storage }
func (*S3StorageFile) ReadAll ¶
func (f *S3StorageFile) ReadAll() ([]byte, error)
func (*S3StorageFile) Size ¶
func (f *S3StorageFile) Size() int64
type Storage ¶
type Storage interface { Save(filepath string, file File) error Path(filepath string) string Exists(filepath string) bool Delete(filepath string) error Open(filepath string) (File, error) ModifiedTime(filepath string) (time.Time, error) Size(filepath string) int64 URL(filename string) string HasBaseURL() bool }
func NewFileSystemStorage ¶
NewStorage returns a file system storage engine
Click to show internal directories.
Click to hide internal directories.