Documentation ¶
Index ¶
- Constants
- Variables
- func DownloadRangeS3(dlr Downloader, w io.WriterAt, bucket, key string, start, finish int) error
- func DownloadS3(downloader Downloader, bucket, key string) (*os.File, error)
- func GetObjectInputFromConfig(c *data.SignedUrlConfig, bucket, key string) *s3.GetObjectInput
- func SignedUrl(info S3Info, key string, duration time.Duration, cfg *data.SignedUrlConfig) (string, error)
- func StreamS3(_s3 S3Info, hash string) (io.ReadCloser, error)
- func UploadS3(info S3Info, r io.Reader, ct string, perms string, key string) error
- type ChunkFileService
- type Downloader
- type InitError
- type S3Baked
- type S3Info
- type Service
- func (s *Service) Delete(filepath string) error
- func (s *Service) Download(filepath string, w io.WriterAt, p *data.DownloadParams) error
- func (s *Service) DownloadRange(filepath string, w io.WriterAt, start, finish int) error
- func (s *Service) Exists(filepath string) (bool, error)
- func (s *Service) Get(filepath string) (io.ReadCloser, error)
- func (s *Service) Head(filepath string) (*data.HeadInfo, error)
- func (s *Service) Init(id, secret string) error
- func (s *Service) Put(filepath string, r io.Reader) error
- func (s *Service) SetConcurrency(concurrency int)
- func (s *Service) SetTimeout(tm time.Duration)
- func (s *Service) SignedUrl(filename string, tm time.Duration, config *data.SignedUrlConfig) (string, error)
- func (s *Service) Stream(filepath string, w io.Writer) error
- func (s *Service) Upload(filepath string, filesize int, r io.Reader) error
- type UploadError
- type Uploader
Constants ¶
const DefaultChunkSizeLimit = 1024 * 1024 * 50
const DefaultIncompleteExpiry = time.Hour * 24
const (
TempDirectoryEnv = "TEMP_DIR" // Would just use default temp directory if not specified
)
Variables ¶
var ( ErrResumedUploadOffsetInvalid = errors.New("offset does not match uploaded status") ErrTimeout = errors.New("timeout") )
Functions ¶
func DownloadRangeS3 ¶
func DownloadS3 ¶
func DownloadS3(downloader Downloader, bucket, key string) (*os.File, error)
func GetObjectInputFromConfig ¶
func GetObjectInputFromConfig(c *data.SignedUrlConfig, bucket, key string) *s3.GetObjectInput
Types ¶
type ChunkFileService ¶
type ChunkFileService struct { Bucket string Client *s3.S3 // Filepath stored from initialization Filepath string // contains filtered or unexported fields }
ChunkFileService is a data.ChunkFileService specific for FS.
func (*ChunkFileService) Cleanup ¶
func (s *ChunkFileService) Cleanup()
Cleanup should delete the ChunkFileService and do any other cleanup necessary. It is only called when an incomplete upload has timed out.
func (*ChunkFileService) CompleteUpload ¶
func (s *ChunkFileService) CompleteUpload() error
CompleteUpload should perform any necessary steps to finalize the multipart upload.
func (*ChunkFileService) InitializeChunk ¶
func (s *ChunkFileService) InitializeChunk(u *data.ChunkUpload) error
InitializeChunk initializes the chunk upload operation.
func (*ChunkFileService) IsInitialized ¶
func (s *ChunkFileService) IsInitialized() bool
IsInitialized should return true if the ChunkFileService has already been initialized.
func (*ChunkFileService) UploadPart ¶
func (s *ChunkFileService) UploadPart(part []byte) error
UploadPart should upload the provided bytes to the cloud. Uploaded parts should be completely sequential.
type Downloader ¶
type Downloader interface {
Download(w io.WriterAt, i *s3.GetObjectInput, options ...func(*s3manager.Downloader)) (int64, error)
}
Wrapper around Service Downloader for stubbing
func NewConcurrentDownloader ¶
func NewConcurrentDownloader(info S3Info, count int) Downloader
func NewDownloader ¶
func NewDownloader(info S3Info) Downloader
func NewOrderedDownloader ¶
func NewOrderedDownloader(info S3Info) Downloader
type S3Baked ¶
type S3Baked struct { Bucket string HashPrefix string Region string // contains filtered or unexported fields }
func (*S3Baked) DefaultBucket ¶
func (*S3Baked) GetSession ¶
type Service ¶
type Service struct { data.ChunkManager Bucket string Region string Timeout time.Duration Concurrency int // Concurrent downloading Session *session.Session Client *s3.S3 // contains filtered or unexported fields }
Adheres to the data.Service interface
func (*Service) DownloadRange ¶
func (*Service) Get ¶
func (s *Service) Get(filepath string) (io.ReadCloser, error)
Get gets a file reader from Service
func (*Service) SetConcurrency ¶
func (*Service) SetTimeout ¶
type UploadError ¶
type UploadError struct {
// contains filtered or unexported fields
}
func (UploadError) Error ¶
func (e UploadError) Error() string
type Uploader ¶
type Uploader interface {
Upload(input *s3manager.UploadInput, options ...func(*s3manager.Uploader)) (*s3manager.UploadOutput, error)
}
Wrapper around Service Uploader for stubbing