s3

package
v0.0.0-...-54a6da5 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MimeXML mimeType = "application/xml"
)

Variables

This section is empty.

Functions

func EncodeXMLResponse

func EncodeXMLResponse(response interface{}) []byte

Encodes the response headers into XML format.

func NotFoundHandler

func NotFoundHandler(w http.ResponseWriter, r *http.Request)

func WriteAwsXMLResponse

func WriteAwsXMLResponse(w http.ResponseWriter, r *http.Request, statusCode int, result interface{})

func WriteEmptyResponse

func WriteEmptyResponse(w http.ResponseWriter, r *http.Request, statusCode int)

func WriteErrorResponse

func WriteErrorResponse(w http.ResponseWriter, r *http.Request, errorCode ErrorCode)

func WriteResponse

func WriteResponse(w http.ResponseWriter, r *http.Request, statusCode int, response []byte, mType mimeType)

func WriteXMLResponse

func WriteXMLResponse(w http.ResponseWriter, r *http.Request, statusCode int, response interface{})

Types

type APIError

type APIError struct {
	Code           string
	Description    string
	HTTPStatusCode int
}

APIError structure

func GetAPIError

func GetAPIError(code ErrorCode) APIError

GetAPIError provides API Error for input API error code.

type BucketsResult

type BucketsResult struct {
	XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult"`
	Owner   *s3Api.Owner
	Buckets []*s3Api.Bucket `xml:"Buckets>Bucket"`
}

type CopyObjectResult

type CopyObjectResult struct {
	ETag           string    `xml:"ETag"`
	LastModified   time.Time `xml:"LastModified"`
	ChecksumCRC32  string    `xml:"ChecksumCRC32"`
	ChecksumCRC32C string    `xml:"ChecksumCRC32C"`
	ChecksumSHA1   string    `xml:"ChecksumSHA1"`
	ChecksumSHA256 string    `xml:"ChecksumSHA256"`
}

CopyObjectResult upload object result

type ErrorCode

type ErrorCode int

ErrorCode type of error status.

const (
	ErrNone ErrorCode = iota
	ErrAccessDenied
	ErrMethodNotAllowed
	ErrBucketNotEmpty
	ErrBucketAlreadyExists
	ErrBucketAlreadyOwnedByYou
	ErrNoSuchBucket
	ErrNoSuchBucketPolicy
	ErrNoSuchCORSConfiguration
	ErrNoSuchLifecycleConfiguration
	ErrNoSuchKey
	ErrNoSuchUpload
	ErrInvalidBucketName
	ErrInvalidDigest
	ErrInvalidMaxKeys
	ErrInvalidMaxUploads
	ErrInvalidMaxParts
	ErrInvalidMaxDeleteObjects
	ErrInvalidPartNumberMarker
	ErrInvalidPart
	ErrInvalidRange
	ErrInternalError
	ErrInvalidCopyDest
	ErrInvalidCopySource
	ErrInvalidTag
	ErrAuthHeaderEmpty
	ErrSignatureVersionNotSupported
	ErrMalformedPOSTRequest
	ErrPOSTFileRequired
	ErrPostPolicyConditionInvalidFormat
	ErrEntityTooSmall
	ErrEntityTooLarge
	ErrMissingFields
	ErrMissingCredTag
	ErrCredMalformed
	ErrMalformedXML
	ErrMalformedDate
	ErrMalformedPresignedDate
	ErrMalformedCredentialDate
	ErrMissingSignHeadersTag
	ErrMissingSignTag
	ErrUnsignedHeaders
	ErrInvalidQueryParams
	ErrInvalidQuerySignatureAlgo
	ErrExpiredPresignRequest
	ErrMalformedExpires
	ErrNegativeExpires
	ErrMaximumExpires
	ErrSignatureDoesNotMatch
	ErrContentSHA256Mismatch
	ErrInvalidAccessKeyID
	ErrRequestNotReadyYet
	ErrMissingDateHeader
	ErrInvalidRequest
	ErrAuthNotSetup
	ErrNotImplemented
	ErrPreconditionFailed

	ErrExistingObjectIsDirectory
	ErrExistingObjectIsFile

	ErrTooManyRequest
	ErrRequestBytesExceed

	OwnershipControlsNotFoundError
)

Error codes, see full list at http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html

type ListBucketResult

type ListBucketResult struct {
	IsTruncated bool           `xml:"IsTruncated"`
	Contents    []s3Api.Object `xml:"Contents"`
	Name        string         `xml:"Name"`
	Prefix      string         `xml:"Prefix"`
	MaxKeys     int            `xml:"MaxKeys"`
}

type RESTErrorResponse

type RESTErrorResponse struct {
	XMLName    xml.Name `xml:"Error" json:"-"`
	Code       string   `xml:"Code" json:"Code"`
	Message    string   `xml:"Message" json:"Message"`
	Resource   string   `xml:"Resource" json:"Resource"`
	RequestID  string   `xml:"RequestId" json:"RequestId"`
	Key        string   `xml:"Key,omitempty" json:"Key,omitempty"`
	BucketName string   `xml:"BucketName,omitempty" json:"BucketName,omitempty"`

	// Underlying HTTP status code for the returned error
	StatusCode int `xml:"-" json:"-"`
}

RESTErrorResponse - error response format

func (RESTErrorResponse) Error

func (e RESTErrorResponse) Error() string

Error - Returns S3 error string.

type S3Gateway

type S3Gateway struct {
	*client.Client
}

Provide S3 API implementation

func NewS3Gateway

func NewS3Gateway(natsServers string, options []nats.Option) (s3Gateway *S3Gateway)

func (*S3Gateway) Download

func (s3Gateway *S3Gateway) Download(w http.ResponseWriter, r *http.Request)

func (*S3Gateway) HeadObject

func (s3Gateway *S3Gateway) HeadObject(w http.ResponseWriter, r *http.Request)

func (*S3Gateway) ListBuckets

func (s3Gateway *S3Gateway) ListBuckets(w http.ResponseWriter, r *http.Request)

func (*S3Gateway) ListObjects

func (s3Gateway *S3Gateway) ListObjects(w http.ResponseWriter, r *http.Request)

func (S3Gateway) RegisterS3Routes

func (s3 S3Gateway) RegisterS3Routes(router *mux.Router)

func (*S3Gateway) SetOptionHeaders

func (s3Gateway *S3Gateway) SetOptionHeaders(w http.ResponseWriter, r *http.Request)

func (*S3Gateway) Upload

func (s3Gateway *S3Gateway) Upload(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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