本文整理匯總了Golang中github.com/mitchellh/goamz/s3.Bucket.PutReaderHeader方法的典型用法代碼示例。如果您正苦於以下問題:Golang Bucket.PutReaderHeader方法的具體用法?Golang Bucket.PutReaderHeader怎麽用?Golang Bucket.PutReaderHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mitchellh/goamz/s3.Bucket
的用法示例。
在下文中一共展示了Bucket.PutReaderHeader方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: rawUpload
func (s3p *s3Provider) rawUpload(opts *Options, b *s3.Bucket, a *artifact.Artifact) error {
dest := a.FullDest()
reader, err := a.Reader()
if err != nil {
return err
}
ctype := a.ContentType()
size, err := a.Size()
if err != nil {
return err
}
downloadHost := s3p.getRegion().S3BucketEndpoint
if downloadHost == "" {
downloadHost = fmt.Sprintf("https://%s.s3.amazonaws.com", b.Name)
}
s3p.log.WithFields(logrus.Fields{
"download_url": fmt.Sprintf("%s/%s", downloadHost, dest),
}).Info(fmt.Sprintf("uploading: %s (size: %s)", a.Source, humanize.Bytes(size)))
s3p.log.WithFields(logrus.Fields{
"percent_max_size": pctMax(size, opts.MaxSize),
"max_size": humanize.Bytes(opts.MaxSize),
"source": a.Source,
"dest": dest,
"bucket": b.Name,
"content_type": ctype,
"cache_control": opts.CacheControl,
}).Debug("more artifact details")
err = b.PutReaderHeader(dest, reader, int64(size),
map[string][]string{
"Content-Type": []string{ctype},
"Cache-Control": []string{opts.CacheControl},
}, a.Perm)
if err != nil {
return err
}
return nil
}