Version: v0.0.0-...-b425644 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 19 Imported by: 0




View Source
const (
	DEFAULT_ENDPOINT_HOST         = "s3.amazonaws.com"
	HEADER_CONTENT_MD5            = "Content-Md5"
	HEADER_CONTENT_TYPE           = "Content-Type"
	HEADER_DATE                   = "Date"
	HEADER_AUTHORIZATION          = "Authorization"
	AMZ_ACL_PUBLIC                = "public-read"
	DEFAULT_CONTENT_TYPE          = "application/octet-stream"
	HEADER_AMZ_ACL                = "x-amz-acl"
	HEADER_SERVER_SIDE_ENCRUPTION = "x-amz-server-side-encryption"
	AES256                        = "AES256"
View Source
const MinPartSize = 5 * 1024 * 1024


This section is empty.


This section is empty.


type AccessControlList

type AccessControlList struct {
	Grants []*Grant `xml:"Grant"`

type AccessControlPolicy

type AccessControlPolicy struct {
	XMLname           xml.Name           `xml:"AccessControlPolicy"`
	Owner             *User              `xml:"Owner"`
	AccessControlList *AccessControlList `xml:"AccessControlList"`

type Acl

type Acl struct {
	Bucket string
	Key    string

func (*Acl) Load

func (acl *Acl) Load(client *Client) (*AccessControlPolicy, error)

type ApiError

type ApiError struct {
	Message      string
	Request      *http.Request
	Response     *http.Response
	ResponseBody []byte

func NewApiError

func NewApiError(message string, req *http.Request, rsp *http.Response, body []byte) *ApiError

func (ApiError) Error

func (e ApiError) Error() string

type Bucket

type Bucket struct {
	Name         string    `xml:"Name"`
	CreationDate time.Time `xml:"CreationDate"`

type Client

type Client struct {
	CustomEndpointHost string

func NewFromEnv

func NewFromEnv() *Client

func (*Client) CompleteMultipartUpload

func (client *Client) CompleteMultipartUpload(bucket, key, uploadId string, parts []*Part) (result *CompleteMultipartUploadResult, e error)

func (*Client) Copy

func (client *Client) Copy(srcBucket, srcKey, tgtBucket, tgtKey string) error

func (*Client) Delete

func (client *Client) Delete(bucket, key string) error

func (*Client) Endpoint

func (client *Client) Endpoint() string

func (*Client) EndpointHost

func (client *Client) EndpointHost() string

func (*Client) Get

func (client *Client) Get(bucket, key string) (*http.Response, error)

func (*Client) Head

func (client *Client) Head(bucket, key string) (*http.Response, error)

func (*Client) InitiateMultipartUpload

func (client *Client) InitiateMultipartUpload(bucket, key string, opts *PutOptions) (result *InitiateMultipartUploadResult, e error)

func (*Client) ListBucket

func (client *Client) ListBucket(bucket string) (r *ListBucketResult, e error)

func (*Client) ListBucketWithOptions

func (client *Client) ListBucketWithOptions(bucket string, opts *ListBucketOptions) (r *ListBucketResult, e error)

func (*Client) Put

func (client *Client) Put(bucket, key string, data []byte, options *PutOptions) error

func (*Client) PutMultipart

func (client *Client) PutMultipart(bucket, key string, f io.Reader, opts *MultipartOptions) (res *CompleteMultipartUploadResult, e error)

func (*Client) PutStream

func (client *Client) PutStream(bucket, key string, r io.Reader, options *PutOptions) error

func (*Client) Service

func (client *Client) Service() (r *ListAllMyBucketsResult, e error)

func (*Client) SignS3Request

func (client *Client) SignS3Request(req *http.Request, bucket string)

func (*Client) UploadPart

func (client *Client) UploadPart(bucket, key string, data []byte, partId int, uploadId string) (part *Part, e error)

type CommonPrefixes

type CommonPrefixes struct {
	Prefix string `xml:"Prefix"`

type CompleteMultipartUpload

type CompleteMultipartUpload struct {
	XMLName xml.Name `xml:"CompleteMultipartUpload"`
	Parts   []*Part  `xml:"Part"`

type CompleteMultipartUploadResult

type CompleteMultipartUploadResult struct {
	XMLName  xml.Name `xml:"CompleteMultipartUploadResult"`
	Location string   `xml:"Location"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	ETag     string   `xml:"ETag"`

type Content

type Content struct {
	Key              string    `xml:"Key"`
	LastModified     time.Time `xml:"LastModified"`
	Etag             string    `xml:"ETag"`
	Size             int64     `xml:"Size"`
	StorageClass     string    `xml:"StorageClass"`
	OwnerID          string    `xml:"Owner>ID"`
	OwnerDisplayName string    `xml:"Owner>DisplayName"`

type Grant

type Grant struct {
	Grantee    *User  `xml:"Grantee"`
	Permission string `xml:"Permission"`

type InitiateMultipartUploadResult

type InitiateMultipartUploadResult struct {
	XMLName  xml.Name `xml:"InitiateMultipartUploadResult"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	UploadId string   `xml:"UploadId"`

type ListAllMyBucketsResult

type ListAllMyBucketsResult struct {
	XMLName          xml.Name `xml:"ListAllMyBucketsResult"`
	OwnerID          string   `xml:"Owner>ID"`
	OwnerDisplayName string   `xml:"Owner>DisplayName"`

	Buckets []*Bucket `xml:"Buckets>Bucket"`

type ListBucketOptions

type ListBucketOptions struct {
	Marker string
	Prefix string

type ListBucketResult

type ListBucketResult struct {
	XMLName     xml.Name `xml:"ListBucketResult"`
	Name        string   `xml:"Name"`
	Prefix      string   `xml:"Prefix"`
	Marker      string   `xml:"Marker"`
	MaxKeys     int      `xml:"MaxKeys"`
	IsTruncated bool     `xml:"IsTruncated"`

	Contents []*Content `xml:"Contents"`

type ListVersions

type ListVersions struct {
	Bucket string

	// for parameter
	Delimiter       string
	EncodingType    string
	KeyMarker       string
	MaxKeys         string
	Prefix          string
	VersionIdMarker string

func (*ListVersions) Execute

func (a *ListVersions) Execute(client *Client) (*ListVersionsResult, error)

type ListVersionsResult

type ListVersionsResult struct {
	Name            string            `xml:"Name"`            // example-bucket</Name>
	Prefix          string            `xml:"Prefix"`          // photos/2006/</Prefix>
	KeyMarker       string            `xml:"KeyMarker"`       // </KeyMarker>
	VersionIdMarker string            `xml:"VersionIdMarker"` // </VersionIdMarker>
	MaxKeys         int               `xml:"MaxKeys"`         // 1000</MaxKeys>
	Delimiter       string            `xml:"Delimiter"`       // /</Delimiter>
	IsTruncated     bool              `xml:"IsTruncated"`     // false</IsTruncated>
	CommonPrefixes  []*CommonPrefixes `xml:"CommonPrefixes"`
	Versions        []*Version        `xml:"Version"`

type MultipartOptions

type MultipartOptions struct {
	PartSize int
	Callback func(*UploadPartResult)

type Owner

type Owner struct {
	ID          string `xml:"ID"`
	DisplayName string `xml:"DisplayName"`

type Part

type Part struct {
	ETag       string
	PartNumber int

type Policy

type Policy struct {
	Id         string             `json:"Id,omitempty"`
	Version    string             `json:"Version,omitempty"`
	Statements []*PolicyStatement `json:"Statement,omitempty"`

type PolicyRequest

type PolicyRequest struct {
	Bucket string
	Key    string

func (*PolicyRequest) Load

func (pr *PolicyRequest) Load(client *Client) (*AccessControlPolicy, error)

type PolicyStatement

type PolicyStatement struct {
	Condition interface{} `json:"Condition"`
	Resource  string      `json:"Resource,omitempty"`
	Action    string      `json:"Action,omitempty"`
	Principal interface{} `json:"Principal,omitempty"`
	Effect    string      `json:"Effect,omitempty"`
	Sid       string      `json:"Sid,omitempty"`

type PutOptions

type PutOptions struct {
	ContentType          string
	ContentLength        int
	ContentEncoding      string
	AmzAcl               string
	ServerSideEncryption bool
	MetaHeader           http.Header

func NewPublicPut

func NewPublicPut() *PutOptions

type UploadPartResult

type UploadPartResult struct {
	CurrentSize int
	Part        *Part
	Error       error

type User

type User struct {
	ID          string `xml:"ID"`          // Owner-canonical-user-ID</ID>
	DisplayName string `xml:"DisplayName"` // display-name</DisplayName>
	URI         string `xml:"URI"`

type Version

type Version struct {
	Key          string `xml:"Key"`          // photos/2006/</Key>
	VersionId    string `xml:"VersionId"`    // 3U275dAA4gz8ZOqOPHtJCUOi60krpCdy</VersionId>
	IsLatest     string `xml:"IsLatest"`     // true</IsLatest>
	LastModified string `xml:"LastModified"` // 2011-02-02T18:47:27.000Z</LastModified>
	ETag         string `xml:"ETag"`         // &quot;d41d8cd98f00b204e9800998ecf8427e&quot;</ETag>
	Size         string `xml:"Size"`         // 0</Size>
	Owner        *Owner `xml:"Owner"`
	StorageClass string `xml:"StorageClass"` // STANDARD</StorageClass>

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL