Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAwsSessionFromEnv ¶
NewAwsSessionFromEnv creates a new aws session from environment variables.
Types ¶
type FileNameStrategy ¶
FileNameStrategy is a callable used for naming a file.
func Crc32TimeNamingStrategy ¶
func Crc32TimeNamingStrategy() FileNameStrategy
Crc32TimeNamingStrategy returns the crc32 encoded string of the unix time in nanoseconds plus the file extension of the given basename.
type HTTPClient ¶
HTTPClient is the interface for interacting with http calls.
type S3Client ¶
type S3Client interface { GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput, error) PutObject(input *s3.PutObjectInput) (*s3.PutObjectOutput, error) }
S3Client is the interface for interacting with S3-related stuff.
type S3Downloader ¶
type S3Downloader interface {
Download(w io.WriterAt, input *s3.GetObjectInput, options ...func(*s3manager.Downloader)) (n int64, err error)
}
S3Downloader downloads files from s3.
type S3Storage ¶
type S3Storage struct {
// contains filtered or unexported fields
}
S3Storage is the Storage implementation for AWS S3.
func NewS3Storage ¶
func NewS3Storage(httpClient HTTPClient, s3 S3Client, s3Downloader S3Downloader, bucket string, opts ...S3StorageOption) *S3Storage
NewS3Storage creates a new S3 storage implementation from params.
func NewS3StorageFromEnv ¶
NewS3StorageFromEnv creates the new S3 storage implementation from env vars.
func (*S3Storage) UploadBytes ¶
UploadBytes uploads an item as bytes with the specified name.
func (*S3Storage) UploadFromRemote ¶
func (storage *S3Storage) UploadFromRemote(remoteFile string, remoteDir string) (UploadedImage, error)
UploadFromRemote uploads a file from a remote url. The remote file gets temporarily read in memory.
type S3StorageOption ¶
type S3StorageOption func(*S3Storage)
S3StorageOption sets optional parameters.
func NamingStrategy ¶
func NamingStrategy(strategy FileNameStrategy) S3StorageOption
NamingStrategy sets the naming strategy for the storage.
type Storage ¶
type Storage interface { Download(key string) (*bytes.Reader, error) UploadFromRemote(remoteURL string, remoteDir string) (UploadedImage, error) UploadBytes(b *bytes.Buffer, remotePathName string) error }
Storage defines the interface for uploading remote files to a remote directory.
type UploadedImage ¶
UploadedImage is the uploaded image with its pathname and md5 hash of the image data.