github.com/abemedia/appcast@v0.4.0/target/s3/s3.go (about)

     1  package s3
     2  
     3  import (
     4  	"net/url"
     5  
     6  	"github.com/abemedia/appcast/internal/blob"
     7  	"github.com/abemedia/appcast/target"
     8  	_ "gocloud.dev/blob/s3blob" // blob driver
     9  )
    10  
    11  type Config struct {
    12  	Bucket     string
    13  	Folder     string
    14  	Endpoint   string
    15  	Region     string
    16  	DisableSSL bool
    17  	URL        string
    18  }
    19  
    20  func New(c Config) (target.Target, error) {
    21  	q := url.Values{}
    22  	if c.Region != "" {
    23  		q.Add("region", c.Region)
    24  	}
    25  	if c.DisableSSL {
    26  		q.Add("disableSSL", "true")
    27  	}
    28  	if c.Endpoint != "" {
    29  		q.Add("endpoint", c.Endpoint)
    30  		q.Add("s3ForcePathStyle", "true")
    31  	}
    32  	return blob.NewTarget("s3://"+c.Bucket+"?"+q.Encode(), c.Folder, c.URL)
    33  }