Documentation
¶
Index ¶
- Constants
- type AbortMultipartUploadInput
- type AccessControlPolicy
- type Bucket
- type CompleteMultipartUploadInput
- type CompleteMultipartUploadOutput
- type CompletedPart
- type CopyObjectInput
- type CopyObjectOutput
- type CreateBucketInput
- type CreateBucketOutput
- type DeleteBucketInput
- type DeleteError
- type DeleteInput
- type DeleteMarker
- type DeleteObjectTaggingInput
- type DeleteObjectsInput
- type DeleteObjectsOutput
- type DeletedObject
- type DetailsInput
- type DetailsResponse
- type DownloadInput
- type GetBucketVersioningOutput
- type GetObjectAclInput
- type GetObjectTaggingInput
- type GetObjectTaggingOutput
- type Grant
- type Grantee
- type IAMResponse
- type InitiateMultipartUploadInput
- type InitiateMultipartUploadOutput
- type LifecycleAbortIncompleteMultipartUpload
- type LifecycleConfiguration
- type LifecycleExpiration
- type LifecycleFilter
- type LifecycleNoncurrentVersionExpiration
- type LifecycleNoncurrentVersionTransition
- type LifecycleRule
- type LifecycleTransition
- type ListBucketsInput
- type ListBucketsOutput
- type ListInput
- type ListPartsInput
- type ListPartsOutput
- type ListResponse
- type ListVersionsInput
- type ListVersionsResponse
- type MultipartUploadInput
- type MultipartUploadOutput
- type Object
- type ObjectVersion
- type Owner
- type Part
- type PolicyJSON
- type PresignedInput
- type PresignedMultipartInput
- type ProgressFunc
- type ProgressInfo
- type PutBucketAclInput
- type PutBucketLifecycleInput
- type PutBucketVersioningInput
- type PutObjectAclInput
- type PutObjectTaggingInput
- type PutResponse
- type S3
- func (s3 *S3) AbortMultipartUpload(input AbortMultipartUploadInput) error
- func (s3 *S3) CompleteMultipartUpload(input CompleteMultipartUploadInput) (CompleteMultipartUploadOutput, error)
- func (s3 *S3) CopyObject(input CopyObjectInput) (CopyObjectOutput, error)
- func (s3 *S3) CreateBucket(input CreateBucketInput) (CreateBucketOutput, error)
- func (s3 *S3) CreateUploadPolicies(uploadConfig UploadConfig) (UploadPolicies, error)
- func (s3 *S3) DeleteBucket(input DeleteBucketInput) error
- func (s3 *S3) DeleteBucketLifecycle(input DeleteBucketInput) error
- func (s3 *S3) DeleteObjectTagging(input DeleteObjectTaggingInput) error
- func (s3 *S3) DeleteObjects(input DeleteObjectsInput) (DeleteObjectsOutput, error)
- func (s3 *S3) FileDelete(u DeleteInput) error
- func (s3 *S3) FileDetails(u DetailsInput) (DetailsResponse, error)
- func (s3 *S3) FileDownload(u DownloadInput) (io.ReadCloser, error)
- func (s3 *S3) FilePut(u UploadInput) (PutResponse, error)
- func (s3 *S3) FileUpload(u UploadInput) (UploadResponse, error)
- func (s3 *S3) FileUploadMultipart(input MultipartUploadInput) (MultipartUploadOutput, error)
- func (s3 *S3) GeneratePresignedURL(in PresignedInput) string
- func (s3 *S3) GeneratePresignedUploadPartURL(in PresignedMultipartInput) string
- func (s3 *S3) GetBucketAcl(bucket string) (AccessControlPolicy, error)
- func (s3 *S3) GetBucketLifecycle(bucket string) (LifecycleConfiguration, error)
- func (s3 *S3) GetBucketVersioning(bucket string) (GetBucketVersioningOutput, error)
- func (s3 *S3) GetObjectAcl(input GetObjectAclInput) (AccessControlPolicy, error)
- func (s3 *S3) GetObjectTagging(input GetObjectTaggingInput) (GetObjectTaggingOutput, error)
- func (s3 *S3) InitiateMultipartUpload(input InitiateMultipartUploadInput) (InitiateMultipartUploadOutput, error)
- func (s3 *S3) List(input ListInput) (ListResponse, error)
- func (s3 *S3) ListAll(input ListInput) (iter.Seq[Object], func() error)
- func (s3 *S3) ListBuckets(input ListBucketsInput) (ListBucketsOutput, error)
- func (s3 *S3) ListParts(input ListPartsInput) (ListPartsOutput, error)
- func (s3 *S3) ListVersions(input ListVersionsInput) (ListVersionsResponse, error)
- func (s3 *S3) PutBucketAcl(input PutBucketAclInput) error
- func (s3 *S3) PutBucketLifecycle(input PutBucketLifecycleInput) error
- func (s3 *S3) PutBucketVersioning(input PutBucketVersioningInput) error
- func (s3 *S3) PutObjectAcl(input PutObjectAclInput) error
- func (s3 *S3) PutObjectTagging(input PutObjectTaggingInput) error
- func (s3 *S3) SetClient(client *http.Client) *S3
- func (s3 *S3) SetEndpoint(uri string) *S3
- func (s3 *S3) SetIAMData(iamResp IAMResponse)
- func (s3 *S3) SetToken(token string) *S3
- func (s3 *S3) UploadPart(input UploadPartInput) (UploadPartOutput, error)
- type S3Error
- type Tag
- type UploadConfig
- type UploadInput
- type UploadPartInput
- type UploadPartOutput
- type UploadPolicies
- type UploadResponse
- type VersioningConfiguration
Constants ¶
const ( MinPartSize = 5 * 1024 * 1024 // 5 MB MaxPartSize = 5 * 1024 * 1024 * 1024 // 5 GB MaxParts = 10000 DefaultPartSize = 5 * 1024 * 1024 // 5 MB DefaultMaxRetries = 3 DefaultRetryBaseWait = 100 * time.Millisecond DefaultRetryMaxWait = 5 * time.Second )
Multipart upload constants
const (
// AMZMetaPrefix to prefix metadata key.
AMZMetaPrefix = "x-amz-meta-"
)
const (
HdrXAmzSignedHeaders = "X-Amz-SignedHeaders"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbortMultipartUploadInput ¶ added in v0.11.0
type AbortMultipartUploadInput struct {
Bucket string // Required: bucket name
ObjectKey string // Required: object key
UploadID string // Required: upload ID
}
AbortMultipartUploadInput contains parameters for aborting a multipart upload
type AccessControlPolicy ¶ added in v0.11.0
type AccessControlPolicy struct {
XMLName xml.Name `xml:"AccessControlPolicy"`
XMLNS string `xml:"xmlns,attr,omitempty"`
Owner Owner `xml:"Owner"`
AccessControlList []Grant `xml:"AccessControlList>Grant"`
}
AccessControlPolicy represents the Access Control List (ACL) for a bucket or object.
type CompleteMultipartUploadInput ¶ added in v0.11.0
type CompleteMultipartUploadInput struct {
Bucket string // Required: bucket name
ObjectKey string // Required: object key
UploadID string // Required: upload ID
Parts []CompletedPart // Required: list of parts, ordered by PartNumber
}
CompleteMultipartUploadInput contains parameters for completing a multipart upload
type CompleteMultipartUploadOutput ¶ added in v0.11.0
CompleteMultipartUploadOutput contains the response from completing a multipart upload
type CompletedPart ¶ added in v0.11.0
CompletedPart represents a part that has been uploaded
type CopyObjectInput ¶ added in v0.11.0
type CopyObjectInput struct {
// Required: Source bucket name
SourceBucket string
// Required: Source object key
SourceKey string
// Required: Destination bucket name
DestBucket string
// Required: Destination object key
DestKey string
// Optional: COPY (default) or REPLACE
// COPY - copies metadata from source
// REPLACE - replaces metadata with values specified in this input
MetadataDirective string
// Optional: Content type (only used when MetadataDirective = REPLACE)
ContentType string
// Optional: Custom metadata (only used when MetadataDirective = REPLACE)
CustomMetadata map[string]string
// Optional: Tags to set on the destination object (max 10 tags)
// When set, uses x-amz-tagging-directive: REPLACE
Tags map[string]string
// Optional: Server-side encryption (e.g. "AES256" or "aws:kms")
ServerSideEncryption string
// Optional: KMS Key ID (ARN or ID) when ServerSideEncryption is "aws:kms"
SSEKMSKeyId string
}
CopyObjectInput is passed to CopyObject as a parameter.
type CopyObjectOutput ¶ added in v0.11.0
CopyObjectOutput is returned by CopyObject.
type CreateBucketInput ¶ added in v0.11.0
type CreateBucketInput struct {
// Required: The name of the bucket to create
Bucket string
// Optional: AWS region for the bucket.
// If empty, uses the region from S3 struct.
// Note: For us-east-1, no LocationConstraint is needed.
Region string
}
CreateBucketInput is passed to CreateBucket as a parameter.
type CreateBucketOutput ¶ added in v0.11.0
type CreateBucketOutput struct {
// Location header from the response
Location string
}
CreateBucketOutput is returned by CreateBucket.
type DeleteBucketInput ¶ added in v0.11.0
type DeleteBucketInput struct {
// Required: The name of the bucket to delete
// Note: The bucket must be empty before deletion
Bucket string
}
DeleteBucketInput is passed to DeleteBucket as a parameter.
type DeleteError ¶ added in v0.11.0
type DeleteError struct {
Key string `xml:"Key"`
Code string `xml:"Code"`
Message string `xml:"Message"`
}
DeleteError represents a deletion error.
type DeleteInput ¶
type DeleteInput struct {
Bucket string
ObjectKey string
VersionId string // Optional: Version ID of the object to delete
}
DeleteInput is passed to FileDelete as a parameter.
type DeleteMarker ¶ added in v0.11.0
type DeleteMarker struct {
IsLatest bool `xml:"IsLatest"`
Key string `xml:"Key"`
LastModified string `xml:"LastModified"`
VersionId string `xml:"VersionId"`
Owner struct {
ID string `xml:"ID"`
DisplayName string `xml:"DisplayName"`
} `xml:"Owner"`
}
DeleteMarker represents a delete marker for an object.
type DeleteObjectTaggingInput ¶ added in v0.11.0
type DeleteObjectTaggingInput struct {
// Required: The name of the bucket
Bucket string
// Required: The object key
ObjectKey string
}
DeleteObjectTaggingInput is passed to DeleteObjectTagging as a parameter.
type DeleteObjectsInput ¶ added in v0.11.0
type DeleteObjectsInput struct {
// Required: The name of the bucket
Bucket string
// Required: List of object keys to delete (max 1000)
Objects []string
// Optional: Quiet mode - only return errors, not successes
Quiet bool
}
DeleteObjectsInput is passed to DeleteObjects as a parameter.
type DeleteObjectsOutput ¶ added in v0.11.0
type DeleteObjectsOutput struct {
Deleted []DeletedObject
Errors []DeleteError
}
DeleteObjectsOutput is returned by DeleteObjects.
type DeletedObject ¶ added in v0.11.0
type DeletedObject struct {
Key string `xml:"Key"`
}
DeletedObject represents a successfully deleted object.
type DetailsInput ¶ added in v0.7.0
type DetailsInput struct {
Bucket string
ObjectKey string
VersionId string // Optional: Version ID of the object to retrieve details for
}
DetailsInput is passed to FileDetails as a parameter.
type DetailsResponse ¶ added in v0.7.0
type DetailsResponse struct {
ContentType string
ContentLength string
AcceptRanges string
Date string
Etag string
LastModified string
Server string
AmzID2 string
AmzRequestID string
// Server-side encryption (e.g. "AES256" or "aws:kms")
ServerSideEncryption string
// KMS Key ID (ARN or ID) when ServerSideEncryption is "aws:kms"
SSEKMSKeyId string
AmzMeta map[string]string
ExtraHeaders map[string]string
}
DetailsResponse is returned by FileDetails.
type DownloadInput ¶ added in v0.5.0
type GetBucketVersioningOutput ¶ added in v0.11.0
GetBucketVersioningOutput is returned by GetBucketVersioning.
type GetObjectAclInput ¶ added in v0.11.0
type GetObjectAclInput struct {
// Required: The name of the bucket
Bucket string
// Required: The object key
ObjectKey string
// Optional: Version ID of the object
VersionId string
}
GetObjectAclInput is passed to GetObjectAcl.
type GetObjectTaggingInput ¶ added in v0.11.0
type GetObjectTaggingInput struct {
// Required: The name of the bucket
Bucket string
// Required: The object key
ObjectKey string
}
GetObjectTaggingInput is passed to GetObjectTagging as a parameter.
type GetObjectTaggingOutput ¶ added in v0.11.0
GetObjectTaggingOutput is returned by GetObjectTagging.
type Grantee ¶ added in v0.11.0
type Grantee struct {
XMLNS string `xml:"xmlns:xsi,attr,omitempty"`
Type string `xml:"xsi:type,attr"` // CanonicalUser, AmazonCustomerByEmail, Group
ID string `xml:"ID,omitempty"`
DisplayName string `xml:"DisplayName,omitempty"`
URI string `xml:"URI,omitempty"` // For Group
EmailAddress string `xml:"EmailAddress,omitempty"` // For AmazonCustomerByEmail
}
Grantee represents the recipient of the permission grant.
type IAMResponse ¶
type IAMResponse struct {
Code string `json:"Code"`
LastUpdated string `json:"LastUpdated"`
Type string `json:"Type"`
AccessKeyID string `json:"AccessKeyId"`
SecretAccessKey string `json:"SecretAccessKey"`
Token string `json:"Token"`
Expiration time.Time `json:"Expiration"`
}
IAMResponse is used by NewUsingIAM to auto detect the credentials.
type InitiateMultipartUploadInput ¶ added in v0.11.0
type InitiateMultipartUploadInput struct {
Bucket string // Required: bucket name
ObjectKey string // Required: object key
ContentType string // Optional: content type
CustomMetadata map[string]string // Optional: x-amz-meta-* headers
ACL string // Optional: x-amz-acl
// Optional: Server-side encryption (e.g. "AES256" or "aws:kms")
ServerSideEncryption string
// Optional: KMS Key ID (ARN or ID) when ServerSideEncryption is "aws:kms"
SSEKMSKeyId string
}
InitiateMultipartUploadInput contains parameters for initiating a multipart upload
type InitiateMultipartUploadOutput ¶ added in v0.11.0
InitiateMultipartUploadOutput contains the response from initiating a multipart upload
type LifecycleAbortIncompleteMultipartUpload ¶ added in v0.11.0
type LifecycleAbortIncompleteMultipartUpload struct {
DaysAfterInitiation int `xml:"DaysAfterInitiation"`
}
LifecycleAbortIncompleteMultipartUpload represents abort action for incomplete uploads.
type LifecycleConfiguration ¶ added in v0.11.0
type LifecycleConfiguration struct {
XMLName xml.Name `xml:"LifecycleConfiguration"`
XMLNS string `xml:"xmlns,attr,omitempty"`
Rules []LifecycleRule `xml:"Rule"`
}
LifecycleConfiguration represents the lifecycle configuration for a bucket.
type LifecycleExpiration ¶ added in v0.11.0
type LifecycleExpiration struct {
Date string `xml:"Date,omitempty"` // ISO 8601 format
Days int `xml:"Days,omitempty"`
ExpiredObjectDeleteMarker bool `xml:"ExpiredObjectDeleteMarker,omitempty"`
}
LifecycleExpiration represents the expiration action.
type LifecycleFilter ¶ added in v0.11.0
type LifecycleFilter struct {
Prefix string `xml:"Prefix,omitempty"`
Tag *Tag `xml:"Tag,omitempty"`
And *struct {
Prefix string `xml:"Prefix,omitempty"`
Tags []Tag `xml:"Tag,omitempty"`
} `xml:"And,omitempty"`
}
LifecycleFilter represents the filter for a lifecycle rule.
type LifecycleNoncurrentVersionExpiration ¶ added in v0.11.0
type LifecycleNoncurrentVersionExpiration struct {
NoncurrentDays int `xml:"NoncurrentDays"`
}
LifecycleNoncurrentVersionExpiration represents expiration for noncurrent versions.
type LifecycleNoncurrentVersionTransition ¶ added in v0.11.0
type LifecycleNoncurrentVersionTransition struct {
NoncurrentDays int `xml:"NoncurrentDays"`
StorageClass string `xml:"StorageClass"`
}
LifecycleNoncurrentVersionTransition represents transition for noncurrent versions.
type LifecycleRule ¶ added in v0.11.0
type LifecycleRule struct {
ID string `xml:"ID,omitempty"`
Status string `xml:"Status"` // Enabled or Disabled
Filter *LifecycleFilter `xml:"Filter,omitempty"`
// Legacy Prefix support (S3 supports both, but prefer Filter for V2)
// If Prefix is provided here, do not use Filter.
Prefix *string `xml:"Prefix,omitempty"`
Expiration *LifecycleExpiration `xml:"Expiration,omitempty"`
Transitions []LifecycleTransition `xml:"Transition,omitempty"`
NoncurrentVersionExpiration *LifecycleNoncurrentVersionExpiration `xml:"NoncurrentVersionExpiration,omitempty"`
NoncurrentVersionTransitions []LifecycleNoncurrentVersionTransition `xml:"NoncurrentVersionTransition,omitempty"`
AbortIncompleteMultipartUpload *LifecycleAbortIncompleteMultipartUpload `xml:"AbortIncompleteMultipartUpload,omitempty"`
}
LifecycleRule represents a single lifecycle rule.
type LifecycleTransition ¶ added in v0.11.0
type LifecycleTransition struct {
Date string `xml:"Date,omitempty"`
Days int `xml:"Days,omitempty"`
StorageClass string `xml:"StorageClass"`
}
LifecycleTransition represents a transition action.
type ListBucketsInput ¶ added in v0.11.0
type ListBucketsInput struct {
}
ListBucketsInput is passed to ListBuckets as a parameter.
type ListBucketsOutput ¶ added in v0.11.0
type ListBucketsOutput struct {
Buckets []Bucket `xml:"Buckets>Bucket"`
Owner struct {
ID string `xml:"ID"`
DisplayName string `xml:"DisplayName"`
} `xml:"Owner"`
}
ListBucketsOutput is returned by ListBuckets.
type ListInput ¶ added in v0.10.0
type ListInput struct {
// Required: The name of the bucket to list objects from
Bucket string
// Optional: A delimiter to group objects by (commonly "/")
Delimiter string
// Optional: Only list objects starting with this prefix
Prefix string
// Optional: Maximum number of objects to return
MaxKeys int64
// Optional: Token for pagination from a previous request
ContinuationToken string
// Optional: Object key to start listing after
StartAfter string
}
ListInput is passed to List as a parameter.
type ListPartsInput ¶ added in v0.11.0
type ListPartsInput struct {
Bucket string // Required: bucket name
ObjectKey string // Required: object key
UploadID string // Required: upload ID
MaxParts int // Optional: default 1000, max 1000
PartNumberMarker int // Optional: for pagination
}
ListPartsInput contains parameters for listing parts
type ListPartsOutput ¶ added in v0.11.0
type ListPartsOutput struct {
Bucket string
Key string
UploadID string
Parts []Part
IsTruncated bool
NextPartNumberMarker int
MaxParts int
}
ListPartsOutput contains the response from listing parts
type ListResponse ¶ added in v0.10.0
type ListResponse struct {
// Name of the bucket
Name string
// Whether the results were truncated (more results available)
IsTruncated bool
// Token to get the next page of results (if truncated)
NextContinuationToken string
// List of objects in the bucket
Objects []Object
// Common prefixes when using delimiter (like directories)
CommonPrefixes []string
// Total number of keys returned
KeyCount int64
}
ListResponse is returned by List.
type ListVersionsInput ¶ added in v0.11.0
type ListVersionsInput struct {
// Required: The name of the bucket to list versions from
Bucket string
// Optional: A delimiter to group objects by (commonly "/")
Delimiter string
// Optional: Only list objects starting with this prefix
Prefix string
// Optional: Maximum number of objects to return
MaxKeys int64
// Optional: Key to start listing after (used for pagination)
KeyMarker string
// Optional: Version ID to start listing after (used for pagination)
VersionIdMarker string
}
ListVersionsInput is passed to ListVersions as a parameter.
type ListVersionsResponse ¶ added in v0.11.0
type ListVersionsResponse struct {
Name string `xml:"Name"`
Prefix string `xml:"Prefix"`
KeyMarker string `xml:"KeyMarker"`
VersionIdMarker string `xml:"VersionIdMarker"`
MaxKeys int64 `xml:"MaxKeys"`
Delimiter string `xml:"Delimiter"`
IsTruncated bool `xml:"IsTruncated"`
NextKeyMarker string `xml:"NextKeyMarker"`
NextVersionIdMarker string `xml:"NextVersionIdMarker"`
Versions []ObjectVersion `xml:"Version"`
DeleteMarkers []DeleteMarker `xml:"DeleteMarker"`
CommonPrefixes []string
}
ListVersionsResponse is returned by ListVersions.
type MultipartUploadInput ¶ added in v0.11.0
type MultipartUploadInput struct {
Bucket string // Required: bucket name
ObjectKey string // Required: object key
Body io.Reader // Required: file/data to upload
ContentType string // Optional: content type
CustomMetadata map[string]string // Optional: x-amz-meta-* headers
ACL string // Optional: x-amz-acl
PartSize int64 // Optional: default 5MB, min 5MB
MaxRetries int // Optional: default 3
Concurrency int // Optional: default 1 (sequential)
OnProgress ProgressFunc // Optional: progress callback
// Optional: Server-side encryption (e.g. "AES256" or "aws:kms")
ServerSideEncryption string
// Optional: KMS Key ID (ARN or ID) when ServerSideEncryption is "aws:kms"
SSEKMSKeyId string
}
MultipartUploadInput contains parameters for the high-level multipart upload
type MultipartUploadOutput ¶ added in v0.11.0
type MultipartUploadOutput struct {
Location string
Bucket string
Key string
ETag string
UploadID string
}
MultipartUploadOutput contains the response from a multipart upload
type Object ¶ added in v0.10.0
type Object struct {
// Name of the object
Key string
// Size in bytes
Size int64
// When the object was last modified
LastModified string
// Entity tag of the object
ETag string
// Storage class (e.g., "STANDARD")
StorageClass string
}
Object represents an S3 object in a bucket.
type ObjectVersion ¶ added in v0.11.0
type ObjectVersion struct {
ETag string `xml:"ETag"`
IsLatest bool `xml:"IsLatest"`
Key string `xml:"Key"`
LastModified string `xml:"LastModified"`
Size int64 `xml:"Size"`
StorageClass string `xml:"StorageClass"`
VersionId string `xml:"VersionId"`
Owner struct {
ID string `xml:"ID"`
DisplayName string `xml:"DisplayName"`
} `xml:"Owner"`
}
ObjectVersion represents a version of an object.
type Owner ¶ added in v0.11.0
type Owner struct {
ID string `xml:"ID,omitempty"`
DisplayName string `xml:"DisplayName,omitempty"`
}
Owner represents the owner of the bucket or object.
type PolicyJSON ¶
type PolicyJSON struct {
Expiration string `json:"expiration"`
Conditions []interface{} `json:"conditions"`
}
PolicyJSON is policy rule.
type PresignedInput ¶
type PresignedInput struct {
Bucket string
ObjectKey string
Method string
Timestamp time.Time
ExtraHeaders map[string]string
ExpirySeconds int
ResponseContentDisposition string
}
PresignedInput is passed to GeneratePresignedURL as a parameter.
type PresignedMultipartInput ¶ added in v0.11.0
type PresignedMultipartInput struct {
Bucket string // Required: bucket name
ObjectKey string // Required: object key
UploadID string // Required: upload ID from InitiateMultipartUpload
PartNumber int // Required: part number (1-10000)
ExpirySeconds int // Optional: default 3600
}
PresignedMultipartInput contains parameters for generating presigned multipart upload URLs
type ProgressFunc ¶ added in v0.11.0
type ProgressFunc func(info ProgressInfo)
ProgressFunc is called during upload with progress information
type ProgressInfo ¶ added in v0.11.0
type ProgressInfo struct {
TotalBytes int64 // Total bytes to upload (if known)
UploadedBytes int64 // Bytes uploaded so far
CurrentPart int // Current part number
TotalParts int // Total parts (if known)
BytesPerSecond int64 // Current upload speed
}
ProgressInfo contains progress information for a multipart upload
type PutBucketAclInput ¶ added in v0.11.0
type PutBucketAclInput struct {
// Required: The name of the bucket
Bucket string
// Optional: Canned ACL (private, public-read, public-read-write, authenticated-read)
// If CannedACL is set, AccessControlPolicy is ignored.
CannedACL string
// Optional: Full Access Control Policy
AccessControlPolicy *AccessControlPolicy
}
PutBucketAclInput is passed to PutBucketAcl.
type PutBucketLifecycleInput ¶ added in v0.11.0
type PutBucketLifecycleInput struct {
// Required: The name of the bucket
Bucket string
// Required: The lifecycle configuration
Configuration *LifecycleConfiguration
}
PutBucketLifecycleInput is passed to PutBucketLifecycle.
type PutBucketVersioningInput ¶ added in v0.11.0
type PutBucketVersioningInput struct {
// Required: The name of the bucket
Bucket string
// Required: Versioning status (Enabled or Suspended)
Status string
// Optional: MFA Delete status (Enabled or Disabled)
// Note: Requires MFA authentication in the request, which is not yet supported
MfaDelete string
}
PutBucketVersioningInput is passed to PutBucketVersioning as a parameter.
type PutObjectAclInput ¶ added in v0.11.0
type PutObjectAclInput struct {
// Required: The name of the bucket
Bucket string
// Required: The object key
ObjectKey string
// Optional: Version ID of the object
VersionId string
// Optional: Canned ACL (private, public-read, public-read-write, authenticated-read)
// If CannedACL is set, AccessControlPolicy is ignored.
CannedACL string
// Optional: Full Access Control Policy
AccessControlPolicy *AccessControlPolicy
}
PutObjectAclInput is passed to PutObjectAcl.
type PutObjectTaggingInput ¶ added in v0.11.0
type PutObjectTaggingInput struct {
// Required: The name of the bucket
Bucket string
// Required: The object key
ObjectKey string
// Required: Tags to set on the object (max 10 tags)
Tags map[string]string
}
PutObjectTaggingInput is passed to PutObjectTagging as a parameter.
type PutResponse ¶ added in v0.8.0
PutResponse is returned when the action is successful, and the service sends back an HTTP 200 response. The response returns ETag along with HTTP headers.
type S3 ¶
type S3 struct {
AccessKey string
SecretKey string
Region string
Client *http.Client
Token string
Endpoint string
URIFormat string
// contains filtered or unexported fields
}
S3 provides a wrapper around your S3 credentials.
func NewUsingIAM ¶
NewUsingIAM automatically generates an Instance of S3 using instance metatdata.
func (*S3) AbortMultipartUpload ¶ added in v0.11.0
func (s3 *S3) AbortMultipartUpload(input AbortMultipartUploadInput) error
AbortMultipartUpload aborts a multipart upload and cleans up parts
func (*S3) CompleteMultipartUpload ¶ added in v0.11.0
func (s3 *S3) CompleteMultipartUpload(input CompleteMultipartUploadInput) (CompleteMultipartUploadOutput, error)
CompleteMultipartUpload completes a multipart upload
func (*S3) CopyObject ¶ added in v0.11.0
func (s3 *S3) CopyObject(input CopyObjectInput) (CopyObjectOutput, error)
CopyObject copies an object from source to destination. Can copy within the same bucket or across buckets. This operation is server-side, avoiding download/upload cycle.
func (*S3) CreateBucket ¶ added in v0.11.0
func (s3 *S3) CreateBucket(input CreateBucketInput) (CreateBucketOutput, error)
CreateBucket creates a new S3 bucket. For regions other than us-east-1, it sends a LocationConstraint in the request body.
func (*S3) CreateUploadPolicies ¶
func (s3 *S3) CreateUploadPolicies(uploadConfig UploadConfig) (UploadPolicies, error)
CreateUploadPolicies creates amazon s3 sigv4 compatible policy and signing keys with the signature returns the upload policy. https://docs.aws.amazon.com/ja_jp/AmazonS3/latest/API/sigv4-authentication-HTTPPOST.html
func (*S3) DeleteBucket ¶ added in v0.11.0
func (s3 *S3) DeleteBucket(input DeleteBucketInput) error
DeleteBucket deletes an empty S3 bucket. The bucket must be empty (no objects) before it can be deleted. Returns an error if the bucket is not empty or does not exist.
func (*S3) DeleteBucketLifecycle ¶ added in v0.11.0
func (s3 *S3) DeleteBucketLifecycle(input DeleteBucketInput) error
DeleteBucketLifecycle deletes the lifecycle configuration for a bucket.
func (*S3) DeleteObjectTagging ¶ added in v0.11.0
func (s3 *S3) DeleteObjectTagging(input DeleteObjectTaggingInput) error
DeleteObjectTagging removes all tags from an S3 object.
func (*S3) DeleteObjects ¶ added in v0.11.0
func (s3 *S3) DeleteObjects(input DeleteObjectsInput) (DeleteObjectsOutput, error)
DeleteObjects deletes multiple objects in a single request (max 1000). This is more efficient than calling FileDelete multiple times. Returns both successful deletions and errors.
func (*S3) FileDelete ¶
func (s3 *S3) FileDelete(u DeleteInput) error
FileDelete makes a DELETE call with the file written as multipart and on successful upload, checks for 204 No Content.
func (*S3) FileDetails ¶ added in v0.7.0
func (s3 *S3) FileDetails(u DetailsInput) (DetailsResponse, error)
func (*S3) FileDownload ¶ added in v0.5.0
func (s3 *S3) FileDownload(u DownloadInput) (io.ReadCloser, error)
FileDownload makes a GET call and returns a io.ReadCloser. After reading the response body, ensure closing the response.
func (*S3) FilePut ¶ added in v0.8.0
func (s3 *S3) FilePut(u UploadInput) (PutResponse, error)
FilePut makes a PUT call to S3.
func (*S3) FileUpload ¶
func (s3 *S3) FileUpload(u UploadInput) (UploadResponse, error)
FileUpload makes a POST call with the file written as multipart and on successful upload, checks for 200 OK.
func (*S3) FileUploadMultipart ¶ added in v0.11.0
func (s3 *S3) FileUploadMultipart(input MultipartUploadInput) (MultipartUploadOutput, error)
FileUploadMultipart handles the entire multipart upload workflow
func (*S3) GeneratePresignedURL ¶
func (s3 *S3) GeneratePresignedURL(in PresignedInput) string
GeneratePresignedURL creates a Presigned URL that can be used for Authentication using Query Parameters. (https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html)
func (*S3) GeneratePresignedUploadPartURL ¶ added in v0.11.0
func (s3 *S3) GeneratePresignedUploadPartURL(in PresignedMultipartInput) string
GeneratePresignedUploadPartURL generates a presigned URL for uploading a specific part This enables browser-based multipart uploads where the frontend uploads parts directly to S3
func (*S3) GetBucketAcl ¶ added in v0.11.0
func (s3 *S3) GetBucketAcl(bucket string) (AccessControlPolicy, error)
GetBucketAcl gets the Access Control List (ACL) for a bucket.
func (*S3) GetBucketLifecycle ¶ added in v0.11.0
func (s3 *S3) GetBucketLifecycle(bucket string) (LifecycleConfiguration, error)
GetBucketLifecycle gets the lifecycle configuration for a bucket.
func (*S3) GetBucketVersioning ¶ added in v0.11.0
func (s3 *S3) GetBucketVersioning(bucket string) (GetBucketVersioningOutput, error)
GetBucketVersioning gets the versioning configuration for a bucket.
func (*S3) GetObjectAcl ¶ added in v0.11.0
func (s3 *S3) GetObjectAcl(input GetObjectAclInput) (AccessControlPolicy, error)
GetObjectAcl gets the Access Control List (ACL) for an object.
func (*S3) GetObjectTagging ¶ added in v0.11.0
func (s3 *S3) GetObjectTagging(input GetObjectTaggingInput) (GetObjectTaggingOutput, error)
GetObjectTagging retrieves the tags associated with an S3 object.
func (*S3) InitiateMultipartUpload ¶ added in v0.11.0
func (s3 *S3) InitiateMultipartUpload(input InitiateMultipartUploadInput) (InitiateMultipartUploadOutput, error)
InitiateMultipartUpload initiates a multipart upload and returns an upload ID
func (*S3) List ¶ added in v0.10.0
func (s3 *S3) List(input ListInput) (ListResponse, error)
List implements a simple S3 object listing API
func (*S3) ListAll ¶ added in v0.10.0
ListAll returns an iterator that yields all objects in the bucket, automatically handling pagination. It also returns a finish callback that should be called after iteration to check for any errors.
func (*S3) ListBuckets ¶ added in v0.11.0
func (s3 *S3) ListBuckets(input ListBucketsInput) (ListBucketsOutput, error)
ListBuckets lists all S3 buckets for the AWS account. It makes a GET request to the S3 service endpoint (not a specific bucket).
func (*S3) ListParts ¶ added in v0.11.0
func (s3 *S3) ListParts(input ListPartsInput) (ListPartsOutput, error)
ListParts lists the parts that have been uploaded for a multipart upload
func (*S3) ListVersions ¶ added in v0.11.0
func (s3 *S3) ListVersions(input ListVersionsInput) (ListVersionsResponse, error)
ListVersions lists object versions in a bucket.
func (*S3) PutBucketAcl ¶ added in v0.11.0
func (s3 *S3) PutBucketAcl(input PutBucketAclInput) error
PutBucketAcl sets the Access Control List (ACL) for a bucket. You can either use a CannedACL OR provide a full AccessControlPolicy.
func (*S3) PutBucketLifecycle ¶ added in v0.11.0
func (s3 *S3) PutBucketLifecycle(input PutBucketLifecycleInput) error
PutBucketLifecycle sets the lifecycle configuration for a bucket.
func (*S3) PutBucketVersioning ¶ added in v0.11.0
func (s3 *S3) PutBucketVersioning(input PutBucketVersioningInput) error
PutBucketVersioning sets the versioning configuration for a bucket.
func (*S3) PutObjectAcl ¶ added in v0.11.0
func (s3 *S3) PutObjectAcl(input PutObjectAclInput) error
PutObjectAcl sets the Access Control List (ACL) for an object. You can either use a CannedACL OR provide a full AccessControlPolicy.
func (*S3) PutObjectTagging ¶ added in v0.11.0
func (s3 *S3) PutObjectTagging(input PutObjectTaggingInput) error
PutObjectTagging sets tags on an existing S3 object. Replaces all existing tags with the provided tags. S3 allows up to 10 tags per object.
func (*S3) SetClient ¶ added in v0.3.0
SetClient can be used to set the http client to be used by the package. If client passed is nil, http.DefaultClient is used.
func (*S3) SetEndpoint ¶ added in v0.5.0
SetEndpoint can be used to the set a custom endpoint for using an alternate instance compatible with the s3 API. If no protocol is included in the URI, defaults to HTTPS.
func (*S3) SetIAMData ¶ added in v0.8.4
func (s3 *S3) SetIAMData(iamResp IAMResponse)
setIAMData sets the IAM data on the S3 instance.
func (*S3) SetToken ¶ added in v0.6.1
SetToken can be used to set a Temporary Security Credential token obtained from using an IAM role or AWS STS.
func (*S3) UploadPart ¶ added in v0.11.0
func (s3 *S3) UploadPart(input UploadPartInput) (UploadPartOutput, error)
UploadPart uploads a single part for a multipart upload
type S3Error ¶ added in v0.10.0
type S3Error struct {
XMLName xml.Name `xml:"Error"`
Code string `xml:"Code"`
Message string `xml:"Message"`
RequestID string `xml:"RequestId"`
HostID string `xml:"HostId"`
}
S3Error represents an S3 API error response
type UploadConfig ¶
type UploadConfig struct {
// Required
BucketName string
ObjectKey string
ContentType string
ContentDisposition string
ACL string
FileSize int64
// Optional
UploadURL string
Expiration time.Duration
MetaData map[string]string
}
UploadConfig generate policies from config for POST requests to S3 using Signing V4.
type UploadInput ¶
type UploadInput struct {
// essential fields
Bucket string
ObjectKey string
FileName string
ContentType string
// optional fields
ContentDisposition string
ACL string
// Setting key/value pairs adds user-defined metadata
// keys to the object, prefixed with AMZMetaPrefix.
CustomMetadata map[string]string
// Setting key/value pairs adds tags to the object (max 10 tags)
Tags map[string]string
// Server-side encryption (e.g. "AES256" or "aws:kms")
ServerSideEncryption string
// KMS Key ID (ARN or ID) when ServerSideEncryption is "aws:kms"
SSEKMSKeyId string
Body io.ReadSeeker
}
UploadInput is passed to FileUpload as a parameter.
type UploadPartInput ¶ added in v0.11.0
type UploadPartInput struct {
Bucket string // Required: bucket name
ObjectKey string // Required: object key
UploadID string // Required: upload ID from InitiateMultipartUpload
PartNumber int // Required: part number (1-10000)
Body io.Reader // Required: part data
Size int64 // Required: size of part for Content-Length
}
UploadPartInput contains parameters for uploading a part
type UploadPartOutput ¶ added in v0.11.0
UploadPartOutput contains the response from uploading a part
type UploadPolicies ¶
UploadPolicies Amazon s3 upload policies.
type UploadResponse ¶ added in v0.2.0
type UploadResponse struct {
Location string `xml:"Location"`
Bucket string `xml:"Bucket"`
Key string `xml:"Key"`
ETag string `xml:"ETag"`
}
UploadResponse receives the following XML in case of success, since we set a 201 response from S3. Sample response:
<PostResponse> <Location>https://s3.amazonaws.com/link-to-the-file</Location> <Bucket>s3-bucket</Bucket> <Key>development/8614bd40-691b-4668-9241-3b342c6cf429/image.jpg</Key> <ETag>"32-bit-tag"</ETag> </PostResponse>
type VersioningConfiguration ¶ added in v0.11.0
type VersioningConfiguration struct {
Status string `xml:"Status"` // Enabled or Suspended
MfaDelete string `xml:"MfaDelete,omitempty"` // Enabled or Disabled
}
VersioningConfiguration represents the versioning configuration of a bucket.