Documentation
¶
Index ¶
- func New(s fs.Storage, opts ...Option) http.Handler
- type Authenticator
- type BucketInfo
- type BucketsWrapper
- type CORSResolver
- type CommonPrefix
- type CompleteMultipartUploadResult
- type CompleteMultipartUploadXML
- type CompletedPartXML
- type CopyObjectResult
- type CopyPartResult
- type DeleteError
- type DeleteObjectsRequest
- type DeleteObjectsResult
- type DeletedObject
- type InitiateMultipartUploadResult
- type ListAllMyBucketsResult
- type ListBucketResult
- type ListMultipartUploadsResult
- type ListPartsResult
- type ListVersionsResult
- type LocationConstraintResult
- type ObjectInfo
- type ObjectToDelete
- type Option
- type PartXML
- type TagSet
- type TagXML
- type Tagging
- type UploadXML
- type VersionEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns the S3-compatible http.Handler for a storage service. Every response carries an x-amz-request-id header; request routing is delegated to route. Options enable authentication and CORS.
Middleware order (outermost first): request-id → CORS → auth → router, so error responses carry a request id, CORS preflight is answered before auth, and only authenticated (or public-read) requests reach the router.
Types ¶
type Authenticator ¶ added in v0.5.0
type Authenticator interface {
// Secret resolves an access key to its secret (for signature verification).
Secret(accessKey string) (secret string, ok bool)
// Allow reports whether the access key may perform action on bucket.
Allow(accessKey, bucket string, action auth.Action) bool
// PublicRead reports whether bucket permits anonymous reads.
PublicRead(bucket string) bool
}
Authenticator verifies credentials and authorizes S3 operations. It is satisfied by *auth.Store.
type BucketInfo ¶
BucketInfo is the XML representation of a bucket.
type BucketsWrapper ¶
type BucketsWrapper struct {
Buckets []BucketInfo `xml:"Bucket"`
}
BucketsWrapper wraps the list of buckets.
type CORSResolver ¶ added in v0.5.0
CORSResolver returns the CORS rules that apply to a bucket.
type CommonPrefix ¶ added in v0.3.0
type CommonPrefix struct {
Prefix string `xml:"Prefix"`
}
CommonPrefix is a grouped key prefix produced by delimiter-based listing.
type CompleteMultipartUploadResult ¶ added in v0.0.4
type CompleteMultipartUploadResult struct {
XMLName xml.Name `xml:"CompleteMultipartUploadResult"`
Xmlns string `xml:"xmlns,attr"`
Location string `xml:"Location"`
Bucket string `xml:"Bucket"`
Key string `xml:"Key"`
ETag string `xml:"ETag"`
}
CompleteMultipartUploadResult represents the response for completing multipart upload.
type CompleteMultipartUploadXML ¶ added in v0.0.4
type CompleteMultipartUploadXML struct {
XMLName xml.Name `xml:"CompleteMultipartUpload"`
Parts []CompletedPartXML `xml:"Part"`
}
CompleteMultipartUploadXML represents the XML request body for completing multipart upload.
type CompletedPartXML ¶ added in v0.0.4
CompletedPartXML represents a part in the completion request.
type CopyObjectResult ¶ added in v0.3.0
type CopyObjectResult struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CopyObjectResult"`
LastModified time.Time `xml:"LastModified"`
ETag string `xml:"ETag"`
}
CopyObjectResult is the XML response for a CopyObject operation.
type CopyPartResult ¶ added in v0.4.0
type CopyPartResult struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CopyPartResult"`
LastModified time.Time `xml:"LastModified"`
ETag string `xml:"ETag"`
}
CopyPartResult is the XML response for an UploadPartCopy operation.
type DeleteError ¶ added in v0.0.5
type DeleteError struct {
Key string `xml:"Key"`
Code string `xml:"Code"`
Message string `xml:"Message"`
VersionId string `xml:"VersionId,omitempty"`
}
DeleteError represents an error deleting an object.
type DeleteObjectsRequest ¶ added in v0.0.5
type DeleteObjectsRequest struct {
XMLName xml.Name `xml:"Delete"`
Objects []ObjectToDelete `xml:"Object"`
Quiet bool `xml:"Quiet"`
}
DeleteObjectsRequest represents the XML request body for deleting multiple objects.
type DeleteObjectsResult ¶ added in v0.0.5
type DeleteObjectsResult struct {
XMLName xml.Name `xml:"DeleteResult"`
Xmlns string `xml:"xmlns,attr"`
Deleted []DeletedObject `xml:"Deleted,omitempty"`
Errors []DeleteError `xml:"Error,omitempty"`
}
DeleteObjectsResult represents the response for deleting multiple objects.
type DeletedObject ¶ added in v0.0.5
type DeletedObject struct {
Key string `xml:"Key"`
VersionId string `xml:"VersionId,omitempty"`
DeleteMarker bool `xml:"DeleteMarker,omitempty"`
DeleteMarkerVersionId string `xml:"DeleteMarkerVersionId,omitempty"`
}
DeletedObject represents a successfully deleted object.
type InitiateMultipartUploadResult ¶ added in v0.0.4
type InitiateMultipartUploadResult struct {
XMLName xml.Name `xml:"InitiateMultipartUploadResult"`
Xmlns string `xml:"xmlns,attr"`
Bucket string `xml:"Bucket"`
Key string `xml:"Key"`
UploadID string `xml:"UploadId"`
}
InitiateMultipartUploadResult represents the response for initiating multipart upload.
type ListAllMyBucketsResult ¶
type ListAllMyBucketsResult struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult"`
Buckets BucketsWrapper `xml:"Buckets"`
}
ListAllMyBucketsResult is the XML response for listing buckets.
type ListBucketResult ¶
type ListBucketResult struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult"`
Name string `xml:"Name"`
Prefix string `xml:"Prefix"`
// V2 pagination.
ContinuationToken string `xml:"ContinuationToken,omitempty"`
NextContinuationToken string `xml:"NextContinuationToken,omitempty"`
StartAfter string `xml:"StartAfter,omitempty"`
// KeyCount is set on every V2 response (including zero) and never on V1.
KeyCount *int `xml:"KeyCount,omitempty"`
// V1 pagination.
Marker string `xml:"Marker,omitempty"`
NextMarker string `xml:"NextMarker,omitempty"`
MaxKeys int `xml:"MaxKeys"`
Delimiter string `xml:"Delimiter,omitempty"`
EncodingType string `xml:"EncodingType,omitempty"`
IsTruncated bool `xml:"IsTruncated"`
Contents []ObjectInfo `xml:"Contents"`
CommonPrefixes []CommonPrefix `xml:"CommonPrefixes"`
}
ListBucketResult is the XML response for ListObjects (v1) and ListObjectsV2.
type ListMultipartUploadsResult ¶ added in v0.4.0
type ListMultipartUploadsResult struct {
XMLName xml.Name `xml:"ListMultipartUploadsResult"`
Xmlns string `xml:"xmlns,attr"`
Bucket string `xml:"Bucket"`
KeyMarker string `xml:"KeyMarker"`
UploadIDMarker string `xml:"UploadIdMarker"`
NextKeyMarker string `xml:"NextKeyMarker,omitempty"`
NextUploadIDMarker string `xml:"NextUploadIdMarker,omitempty"`
Delimiter string `xml:"Delimiter,omitempty"`
Prefix string `xml:"Prefix"`
EncodingType string `xml:"EncodingType,omitempty"`
MaxUploads int `xml:"MaxUploads"`
IsTruncated bool `xml:"IsTruncated"`
Uploads []UploadXML `xml:"Upload"`
CommonPrefixes []CommonPrefix `xml:"CommonPrefixes"`
}
ListMultipartUploadsResult is the XML response for a ListMultipartUploads operation.
type ListPartsResult ¶ added in v0.4.0
type ListPartsResult struct {
XMLName xml.Name `xml:"ListPartsResult"`
Xmlns string `xml:"xmlns,attr"`
Bucket string `xml:"Bucket"`
Key string `xml:"Key"`
UploadID string `xml:"UploadId"`
StorageClass string `xml:"StorageClass"`
PartNumberMarker int `xml:"PartNumberMarker"`
NextPartNumberMarker int `xml:"NextPartNumberMarker,omitempty"`
MaxParts int `xml:"MaxParts"`
IsTruncated bool `xml:"IsTruncated"`
Parts []PartXML `xml:"Part"`
}
ListPartsResult is the XML response for a ListParts operation.
type ListVersionsResult ¶ added in v0.4.0
type ListVersionsResult struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListVersionsResult"`
Name string `xml:"Name"`
Prefix string `xml:"Prefix"`
KeyMarker string `xml:"KeyMarker"`
VersionIDMarker string `xml:"VersionIdMarker"`
NextKeyMarker string `xml:"NextKeyMarker,omitempty"`
NextVersionIDMarker string `xml:"NextVersionIdMarker,omitempty"`
MaxKeys int `xml:"MaxKeys"`
Delimiter string `xml:"Delimiter,omitempty"`
EncodingType string `xml:"EncodingType,omitempty"`
IsTruncated bool `xml:"IsTruncated"`
Versions []VersionEntry `xml:"Version"`
CommonPrefixes []CommonPrefix `xml:"CommonPrefixes"`
}
ListVersionsResult is the XML response for ListObjectVersions (GET /{bucket}?versions).
type LocationConstraintResult ¶ added in v0.4.0
type LocationConstraintResult struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ LocationConstraint"`
Value string `xml:",chardata"`
}
LocationConstraintResult is the XML response for GetBucketLocation. An empty constraint denotes the default region (us-east-1), which is what this single-region server always reports.
type ObjectInfo ¶
type ObjectInfo struct {
Key string `xml:"Key"`
LastModified time.Time `xml:"LastModified"`
ETag string `xml:"ETag,omitempty"`
Size int64 `xml:"Size"`
StorageClass string `xml:"StorageClass,omitempty"`
}
ObjectInfo is the XML representation of an object in a bucket listing.
type ObjectToDelete ¶ added in v0.0.5
ObjectToDelete represents an object to be deleted.
type Option ¶ added in v0.5.0
type Option func(*options)
Option configures the handler built by New.
func WithAuthenticator ¶ added in v0.5.0
func WithAuthenticator(a Authenticator) Option
WithAuthenticator enables SigV4 authentication and grant-based authorization using a. Without it (the library default) the handler serves anonymously.
func WithCORS ¶ added in v0.5.0
func WithCORS(c CORSResolver) Option
WithCORS enables per-bucket CORS: OPTIONS preflight handling and CORS response headers on cross-origin requests, resolved through c.
type PartXML ¶ added in v0.4.0
type PartXML struct {
PartNumber int `xml:"PartNumber"`
LastModified time.Time `xml:"LastModified"`
ETag string `xml:"ETag"`
Size int64 `xml:"Size"`
}
PartXML is a single part entry in a ListPartsResult.
type TagSet ¶ added in v0.4.0
type TagSet struct {
Tags []TagXML `xml:"Tag"`
}
TagSet wraps the list of tags.
type Tagging ¶ added in v0.4.0
type Tagging struct {
XMLName xml.Name `xml:"Tagging"`
Xmlns string `xml:"xmlns,attr,omitempty"`
TagSet TagSet `xml:"TagSet"`
}
Tagging is the XML document for object tagging (both request and response).
type UploadXML ¶ added in v0.4.0
type UploadXML struct {
Key string `xml:"Key"`
UploadID string `xml:"UploadId"`
StorageClass string `xml:"StorageClass"`
Initiated time.Time `xml:"Initiated"`
}
UploadXML is a single in-progress upload entry in a ListMultipartUploadsResult.
type VersionEntry ¶ added in v0.4.0
type VersionEntry struct {
Key string `xml:"Key"`
VersionID string `xml:"VersionId"`
IsLatest bool `xml:"IsLatest"`
LastModified time.Time `xml:"LastModified"`
ETag string `xml:"ETag,omitempty"`
Size int64 `xml:"Size"`
StorageClass string `xml:"StorageClass,omitempty"`
}
VersionEntry is a single object version in a ListObjectVersions response.
The store is unversioned, so every object is reported as a single current version with the well-known VersionId "null" and IsLatest=true — the shape AWS itself returns for objects in a never-versioned bucket.
Source Files
¶
- auth.go
- bucket.go
- chunked.go
- copy_object.go
- cors.go
- create_bucket.go
- delete_bucket.go
- delete_object.go
- delete_objects.go
- error.go
- get_bucket_location.go
- get_object.go
- handler.go
- head_bucket.go
- head_object.go
- list_buckets.go
- list_multipart_uploads.go
- list_object_versions.go
- list_objects.go
- list_parts.go
- metadata.go
- multipart_complete.go
- multipart_upload.go
- multipart_upload_part.go
- object_tagging.go
- put_object.go
- upload_part_copy.go