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) IsNotExist(err error) 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 GCSStorage
- func (gcs *GCSStorage) Delete(filepath string) error
- func (gcs *GCSStorage) Exists(filepath string) bool
- func (gcs *GCSStorage) IsNotExist(err error) bool
- func (gcs *GCSStorage) ModifiedTime(filepath string) (time.Time, error)
- func (gcs *GCSStorage) Open(filepath string) (File, error)
- func (gcs *GCSStorage) Save(path string, file File) error
- func (gcs *GCSStorage) SaveWithContentType(filepath string, file File, contentType string) error
- func (gcs *GCSStorage) Size(filepath string) int64
- type GCSStorageFile
- 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) IsNotExist(err error) 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(path 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 ¶
const LastModifiedFormat = time.RFC1123
Variables ¶
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, }
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) IsNotExist ¶
func (s *FileSystemStorage) IsNotExist(err error) bool
IsNotExist returns a boolean indicating whether the error is known to report that a file or directory does not exist.
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 GCSStorage ¶
type GCSStorage struct { *BaseStorage // contains filtered or unexported fields }
func (*GCSStorage) Delete ¶
func (gcs *GCSStorage) Delete(filepath string) error
Delete the file from the bucket
func (*GCSStorage) Exists ¶
func (gcs *GCSStorage) Exists(filepath string) bool
Exists checks if the given file is in the bucket
func (*GCSStorage) IsNotExist ¶
func (gcs *GCSStorage) IsNotExist(err error) bool
IsNotExist returns a boolean indicating whether the error is known to report that a file or directory does not exist.
func (*GCSStorage) ModifiedTime ¶
func (gcs *GCSStorage) ModifiedTime(filepath string) (time.Time, error)
ModifiedTime returns the last update time
func (*GCSStorage) Open ¶
func (gcs *GCSStorage) Open(filepath string) (File, error)
Open returns the file content in a dedicated bucket
func (*GCSStorage) Save ¶
func (gcs *GCSStorage) Save(path string, file File) error
Save saves a file at the given path in the bucket
func (*GCSStorage) SaveWithContentType ¶
func (gcs *GCSStorage) SaveWithContentType(filepath string, file File, contentType string) error
Save saves a file at the given path in the bucket
func (*GCSStorage) Size ¶
func (gcs *GCSStorage) Size(filepath string) int64
Size returns the size of the given file
type GCSStorageFile ¶
func (*GCSStorageFile) ReadAll ¶
func (f *GCSStorageFile) ReadAll() ([]byte, error)
type S3Storage ¶
type S3Storage struct { *BaseStorage AccessKeyId string SecretAccessKey string BucketName string Region aws.Region ACL s3.ACL }
func (*S3Storage) IsNotExist ¶
IsNotExist returns a boolean indicating whether the error is known to report that a file or directory does not exist.
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 IsNotExist(err error) bool }
func NewFileSystemStorage ¶
NewStorage returns a file system storage engine