// init will initialize all default options. func (u *uploader) init() { if u.opts.S3 == nil { u.opts.S3 = s3.New(nil) } if u.opts.Concurrency == 0 { u.opts.Concurrency = DefaultUploadConcurrency } if u.opts.PartSize == 0 { u.opts.PartSize = DefaultUploadPartSize } // Try to get the total size for some optimizations u.initSize() }
// init initializes the downloader with default options. func (d *downloader) init() { d.totalBytes = -1 if d.opts.Concurrency == 0 { d.opts.Concurrency = DefaultDownloadConcurrency } if d.opts.PartSize == 0 { d.opts.PartSize = DefaultDownloadPartSize } if d.opts.S3 == nil { d.opts.S3 = s3.New(nil) } }
func (s *S3Storage) getService() *s3.S3 { if s.service == nil { config := &aws.Config{ Region: aws.String(os.Getenv("AWS_REGION")), Endpoint: aws.String(os.Getenv("S3_ENDPOINT")), } if os.Getenv("APP_ENV") != "production" { config.DisableSSL = aws.Bool(true) config.S3ForcePathStyle = aws.Bool(true) } s.service = s3.New(config) } return s.service }