コード例 #1
0
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
}
コード例 #2
0
func (ap *artifactsProvider) rawUpload(cl client.ArtifactPutter, a *artifact.Artifact) error {
	ctype := a.ContentType()
	size, err := a.Size()
	if err != nil {
		return err
	}

	ap.log.WithFields(logrus.Fields{
		"percent_max_size": pctMax(size, ap.opts.MaxSize),
		"max_size":         humanize.Bytes(ap.opts.MaxSize),
		"source":           a.Source,
		"dest":             a.FullDest(),
		"content_type":     ctype,
		"cache_control":    ap.opts.CacheControl,
	}).Debug("more artifact details")

	return cl.PutArtifact(a)
}