objectnode

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: Apache-2.0 Imports: 36 Imported by: 2

Documentation

Overview

Package s3 provides ...

Index

Constants

View Source
const (
	//Permission Value
	ReadPermission        Permission = "READ"
	WritePermission                  = "WRITE"
	ReadACPPermission                = "READ_ACP"
	WriteACPPermission               = "WRITE_ACP"
	FullControlPermission            = "FULL_CONTROL"
)
View Source
const (
	PrivateACL                StandardACL = "private"
	PublicReadACL                         = "public-read"
	PubliceReadWriteACL                   = "public-read-write"
	AwsExecReadACL                        = "aws-exec-read"
	AuthenticatedReadACL                  = "authenticated-read"
	BucketOwnerReadACL                    = "bucket-owner-read"
	BucketOwnerFullControlACL             = "bucket-owner-full-control"
	LogDeliveryWriteACL                   = "log-delivery-write"
)
View Source
const (
	OSS_ACL_KEY      = "oss:acl"
	XMLNS            = "http://www.w3.org/2001/XMLSchema-instance"
	XMLXSI           = "CanonicalUser"
	DEF_GRANTEE_TYPE = "CanonicalUser" //

)
View Source
const (
	SignatrueV2 AuthType = "signature_v2"
	SignatrueV4          = "signature_v4"
	PresignedV2          = "presigned_v2"
	PresignedV4          = "presigned_v4"
)
View Source
const (
	RequestHeaderV2Authorization       = "Authorization"
	RequestHeaderV2AuthorizationScheme = "AWS"
	RequestHeaderV2XAmzDate            = "X-Amz-Date"
)
View Source
const (
	MaxPresignedExpires = 3 * 365 * 24 * 60 * 60 //10years
	DateFormatISO8601   = "20060102T150405Z"     //"yyyyMMddTHHmmssZ"
	MaxSkewTime         = 15 * time.Minute

	XAmzContentSha256 = "X-Amz-Content-Sha256"
	XAmzCredential    = "X-Amz-Credential"
	XAmzSignature     = "X-Amz-Signature" //
	XAmzSignedHeaders = "X-Amz-SignedHeaders"
	XAmzAlgorithm     = "X-Amz-Algorithm"
	XAmzDate          = "X-Amz-Date"
	XAmzExpires       = "X-Amz-Expires"

	SignatureV4Algorithm = "AWS4-HMAC-SHA256"
	SignatureV4Request   = "aws4-request"
	SignedHeaderHost     = "host"
	UnsignedPayload      = "UNSIGNED-PAYLOAD"
	PresignedV4QueryAuth = "Authorization"
)
View Source
const (
	HeaderNameServer        = "server"
	HeaderNameHost          = "Host"
	HeaderNameLastModified  = "Last-Modified"
	HeaderNameETag          = "ETag"
	HeaderNameDate          = "Date"
	HeaderNameContentMD5    = "content-md5"
	HeaderNameContentEnc    = "content-encoding"
	HeaderNameContentType   = "Content-Type"
	HeaderNameContentLength = "Content-Length"
	HeaderNameContentRange  = "Content-Range"
	HeaderNameAuthorization = "Authorization"
	HeaderNameAcceptRange   = "Accept-Ranges"
	HeaderNameRange         = "Range"

	HeaderNameStartDate           = "x-amz-date"
	HeaderNameRequestId           = "x-amz-request-id"
	HeaderNameContentHash         = "X-Amz-Content-SHA256"
	HeaderNameCopySource          = "X-Amz-Copy-Source"
	HeaderNameCopyMatch           = "x-amz-copy-source-if-match"
	HeaderNameCopyNoneMatch       = "x-amz-copy-source-if-none-match"
	HeaderNameCopyModified        = "x-amz-copy-source-if-modified-since"
	HeaderNameCopyUnModified      = "x-amz-copy-source-if-unmodified-since"
	HeaderNameDecodeContentLength = "X-Amz-Decoded-Content-Length"
)
View Source
const (
	HeaderValueServer         = "ChubaoFS"
	HeaderValueAcceptRange    = "bytes"
	HeaderValueTypeStream     = "application/octet-stream"
	HeaderValueContentTypeXML = "application/xml"
)
View Source
const (
	SubObjectDelete    = "delete"
	SubMultipartUpload = "uploads"
)
View Source
const (
	ParamUploadId   = "uploadId"
	ParamPartNumber = "partNumber"
	ParamKeyMarker  = "key-marker"
	ParamMarker     = "marker"
	ParamPrefix     = "prefix"
	ParamContToken  = "continuation-token"
	ParamFetchOwner = "fetch-owner"
	ParamMaxKeys    = "max-keys"
	ParamStartAfter = "start-after"

	ParamMaxParts       = "max-parts"
	ParamUploadIdMarker = "upload-id-​marker"
	ParamPartNoMarker   = "part-number-marker"
	ParamPartMaxUploads = "max-uploads"
	ParamPartDelimiter  = "delimiter"
)
View Source
const (
	MaxKeys    = 1000
	MaxParts   = 1000
	MaxUploads = 1000
)
View Source
const (
	XAttrKeyOSSETag    = "oss:etag"
	XAttrKeyOSSTagging = "oss:tg"
	XAttrKeyOSSPolicy  = "oss:ply"
)

XAttr keys for ObjectNode compatible feature

View Source
const (
	PolicyDefaultVersion  = "2012-10-17"
	BucketPolicyLimitSize = 20 * 1024 //Bucket policies are limited to 20KB
	ArnSplitToken         = ":"
)

https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html

View Source
const (
	GetObjectAction                  Action = "s3:GetObject"
	PutObjectAction                         = "s3:PutObject"
	DeleteObjectAction                      = "s3:DeleteObject" //
	HeadObjectAction                        = "s3:HeadObject"
	CreateBucketAction                      = "s3:CreateBucket" //
	ListBucketAction                        = "s3:ListBucket"
	ListBucketVersionsAction                = "s3:ListBucketVersions" // List
	ListBucketMultipartUploadsAction        = "s3:ListBucketMultipartUploads"
	GetBucketPolicyAction                   = "s3:GetBucketPolicy"
	PutBucketPolicyAction                   = "s3:PutBucketPolicy"
	GetBucketAclAction                      = "s3:GetBucketAcl"
	PutBucketAclAction                      = "s3:PutBucketAcl"
	GetObjectAclAction                      = "s3:GetObjectAcl"
	GetObjectVersionAction                  = "s3:GetObjectVersion"
	PutObjectVersionAction                  = "s3:PutObjectVersion"
	GetObjectTorrentAction                  = "s3:GetObjectTorrent"
	PutObjectTorrentAction                  = "s3:PutObjectTorrent"
	PutObjectAclAction                      = "s3:PutObjectAcl"
	GetObjectVersionAclAction               = "s3:GetObjectVersionAcl"
	PutObjectVersionAclAction               = "s3:PutObjectVersionAcl"
	DeleteBucketPolicyAction                = "s3:DeleteBucketPolicy"
	ListMultipartUploadPartsAction          = "s3:ListMultipartUploadParts"
	AbortMultipartUploadAction              = "s3:AbortMultipartUpload"
	GetBucketLocationAction                 = "s3:GetBucketLocation"
)
View Source
const (
	IpAddress                ConditionType = "IpAddress"
	NotIpAddress                           = "NotIpAddress"
	StringLike                             = "StringLike"
	StringNotLike                          = "StringNotLike"
	StringEquals                           = "StringEquals"
	StringNotEquals                        = "StringNotEquals"
	Bool                                   = "Bool"
	DateEquals                             = "DateEquals"
	DateNotEquals                          = "DateNotEquals"
	DateLessThan                           = "DateLessThan"
	DateLessThanEquals                     = "DateLessThanEquals"
	DateGreaterThan                        = "DateGreaterThan"
	DateGreaterThanEquals                  = "DateGreaterThanEquals"
	NumericEquals                          = "NumericEquals"
	NumericNotEquals                       = "NumericNotEquals"
	NumericLessThan                        = "NumericLessThan"
	NumericLessThanEquals                  = "NumericLessThanEquals"
	NumericGreaterThan                     = "NumericGreaterThan"
	NumericGreaterThanEquals               = "NumericGreaterThanEquals"
	ArnEquals                              = "ArnEquals"
	ArnLike                                = "ArnLike" //
	ArnNotEquals                           = "ArnNotEquals"
	ArnNotLike                             = "ArnNotLike" //
)

https://docs.aws.amazon.com/zh_cn/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html

View Source
const (
	AwsCurrentTime            ConditionKey = "aws:CurrentTime"
	AwsEpochTime                           = "aws:EpochTime"
	AwsMultiFactorAuthPresent              = "aws:MultiFactorAuthPresent"
	AwsPrincipalAccount                    = "aws:PrincipalAccount"
	AwsPrincipalArn                        = "aws:PrincipalArn"
	AwsPrincipalOrgID                      = "aws:PrincipalOrgID"
	AwsPrincipalTag                        = "aws:PrincipalTag"
	AwsPrincipalType                       = "aws:PrincipalType"
	AwsReferer                             = "aws:Referer"
	AwsRequestRegion                       = "aws:RequestRegion"
	AwsRequestTagKey                       = "aws:RequestTag/tag-key"
	AwsResourceTagKey                      = "aws:ResourceTag/tag-key"
	AwsSecureTransport                     = "aws:SecureTransport"
	AwsSourceAccout                        = "aws:AwsSourceAccout"
	AwsSourceArn                           = "aws:SourceArn"
	AwsSourceIp                            = "aws:SourceIp"
	AwsSourceVpc                           = "aws:SourceVpc"
	AwsSourceVpce                          = "aws:SourceVpce"
	AwsTagKeys                             = "aws:TagKeys"
	AwsTokenIssueTime                      = "aws:TokenIssueTime"
	AwsUserAgent                           = "aws:UserAgent"
	AwsUserId                              = "aws:userid"
	AwsUserName                            = "aws:username"
	AwsVpcSourceIp                         = "aws:VpcSourceIp"
)

https://docs.aws.amazon.com/zh_cn/IAM/latest/UserGuide/reference_policies_condition-keys.html

View Source
const (
	Standby uint32 = iota
	Start
	Running
	Shutdown
	Stopped
)

The status of the s3 server

View Source
const (
	AMZTimeFormat = "2006-01-02T15:04:05Z"
)
View Source
const (
	EmptyContentMD5String = "d41d8cd98f00b204e9800998ecf8427e"
)
View Source
const (
	LogDeliveryRole = "LogDelivery"
)
View Source
const (
	META_OSS_VOLUME = ".oss_meta"
)
View Source
const (
	OSSMetaUpdateDuration = time.Duration(time.Second * 30)
)
View Source
const (
	StorageClassStandard = "Standard"
)

Variables

View Source
var (
	InvalidParamError = errors.New("invalid param")
	MaxExpiresError   = errors.New("max expires value")
)
View Source
var (
	ErrUnexpectedChunkEnd  = errors.New("unexpected chunk end")
	ErrUnexpectedChunkSize = errors.New("unexpected chunk size")
)
View Source
var (
	UnsupportedOperation                = ErrorCode{ErrorCode: "UnsupportedOperation", ErrorMessage: "Operation is not supported", StatusCode: http.StatusBadRequest}
	AccessDenied                        = ErrorCode{ErrorCode: "AccessDenied", ErrorMessage: "Access Denied", StatusCode: http.StatusForbidden}
	BadDigest                           = ErrorCode{ErrorCode: "BadDigest", ErrorMessage: "The Content-MD5 you specified did not match what we received.", StatusCode: http.StatusBadRequest}
	BucketNotExisted                    = ErrorCode{ErrorCode: "BucketNotExisted", ErrorMessage: "The requested bucket name is not existed.", StatusCode: http.StatusNotFound}
	BucketNotExistedForHead             = ErrorCode{ErrorCode: "BucketNotExisted", ErrorMessage: "The requested bucket name is not existed.", StatusCode: http.StatusConflict}
	BucketNotEmpty                      = ErrorCode{ErrorCode: "BucketNotEmpty", ErrorMessage: "The bucket you tried to delete is not empty.", StatusCode: http.StatusConflict}
	BucketNotOwnedByYou                 = ErrorCode{ErrorCode: "BucketNotOwnedByYou", ErrorMessage: "The bucket is not owned by you.", StatusCode: http.StatusConflict}
	KeyTooLongError                     = ErrorCode{ErrorCode: "KeyTooLongError", ErrorMessage: "", StatusCode: http.StatusBadRequest}
	InvalidKey                          = ErrorCode{ErrorCode: "InvalidKey", ErrorMessage: "Object key is Illegal", StatusCode: http.StatusBadRequest}
	EntityTooSmall                      = ErrorCode{ErrorCode: "EntityTooSmall", ErrorMessage: "Your proposed upload is smaller than the minimum allowed object size.", StatusCode: http.StatusBadRequest}
	EntityTooLarge                      = ErrorCode{ErrorCode: "EntityTooLarge", ErrorMessage: "Your proposed upload exceeds the maximum allowed object size.", StatusCode: http.StatusBadRequest}
	IncorrectNumberOfFilesInPostRequest = ErrorCode{ErrorCode: "IncorrectNumberOfFilesInPostRequest", ErrorMessage: "POST requires exactly one file upload per request.", StatusCode: http.StatusBadRequest}
	InternalError                       = ErrorCode{ErrorCode: "InternalError", ErrorMessage: "We encountered an internal error. Please try again.", StatusCode: http.StatusInternalServerError}
	InvalidArgument                     = ErrorCode{ErrorCode: "InvalidArgument", ErrorMessage: "Invalid Argument", StatusCode: http.StatusBadRequest}
	InvalidBucketName                   = ErrorCode{ErrorCode: "InvalidBucketName", ErrorMessage: "The specified bucket is not valid.", StatusCode: http.StatusBadRequest}
	InvalidRange                        = ErrorCode{ErrorCode: "InvalidRange", ErrorMessage: "The requested range cannot be satisfied.", StatusCode: http.StatusRequestedRangeNotSatisfiable}
	MissingContentLength                = ErrorCode{ErrorCode: "MissingContentLength", ErrorMessage: "You must provide the Content-Length HTTP header.", StatusCode: http.StatusLengthRequired}
	NoSuchBucket                        = ErrorCode{ErrorCode: "NoSuchBucket", ErrorMessage: "The specified bucket does not exist.", StatusCode: http.StatusNotFound}
	NoSuchKey                           = ErrorCode{ErrorCode: "NoLoggingStatusForKey", ErrorMessage: "The specified key does not exist.", StatusCode: http.StatusNotFound}
	PreconditionFailed                  = ErrorCode{ErrorCode: "PreconditionFailed", ErrorMessage: "At least one of the preconditions you specified did not hold.", StatusCode: http.StatusPreconditionFailed}
	MaxContentLength                    = ErrorCode{ErrorCode: "MaxContentLength", ErrorMessage: "Content-Length is bigger than 20KB.", StatusCode: http.StatusLengthRequired}
)
View Source
var ALGORITHM = "HMAC-SHA256"
View Source
var AuthSignatureV4Headers = []string{
	PresignedV4QueryAuth,
	XAmzContentSha256,
}
View Source
var PresignedSignatureV2Queries = []string{
	"AWSAccessKeyId",
	"Signature",
}
View Source
var PresignedSignatureV4Queries = []string{
	XAmzCredential,
	XAmzSignature,
}
View Source
var SCHEME = "AWS4"
View Source
var SERVICE = "s3"
View Source
var SignatureV2WhiteQueries = map[string]struct{}{
	"acl":                          struct{}{},
	"delete":                       struct{}{},
	"lifecycle":                    struct{}{},
	"location":                     struct{}{},
	"logging":                      struct{}{},
	"notification":                 struct{}{},
	"partNumber":                   struct{}{},
	"policy":                       struct{}{},
	"requestPayment":               struct{}{},
	"response-cache-control":       struct{}{},
	"response-content-disposition": struct{}{},
	"response-content-encoding":    struct{}{},
	"response-content-language":    struct{}{},
	"response-content-type":        struct{}{},
	"response-expires":             struct{}{},
	"torrent":                      struct{}{},
	"uploadId":                     struct{}{},
	"uploads":                      struct{}{},
	"versionId":                    struct{}{},
	"versioning":                   struct{}{},
	"versions":                     struct{}{},
}
View Source
var TERMINATOR = "aws4_request"

Functions

func ArnEqualsFunc

func ArnEqualsFunc(p *RequestParam, value ConditionValues) bool

func ArnLikeFunc

func ArnLikeFunc(p *RequestParam, value ConditionValues) bool

func ArnNotEqualsFunc

func ArnNotEqualsFunc(p *RequestParam, value ConditionValues) bool

func ArnNotLikeFunc

func ArnNotLikeFunc(p *RequestParam, value ConditionValues) bool

func BoolFunc

func BoolFunc(p *RequestParam, policyCondtion ConditionValues) bool

func DateEqualsFunc

func DateEqualsFunc(p *RequestParam, policyVals ConditionValues) bool

func DateGreaterThanEqualsFunc

func DateGreaterThanEqualsFunc(p *RequestParam, value ConditionValues) bool

func DateGreaterThanFunc

func DateGreaterThanFunc(p *RequestParam, value ConditionValues) bool

func DateLessThanEqualsFunc

func DateLessThanEqualsFunc(p *RequestParam, value ConditionValues) bool

func DateLessThanFunc

func DateLessThanFunc(p *RequestParam, value ConditionValues) bool

func DateNotEqualsFunc

func DateNotEqualsFunc(p *RequestParam, value ConditionValues) bool

func IpAddressFunc

func IpAddressFunc(p *RequestParam, value ConditionValues) bool

func IsIntersectionActions

func IsIntersectionActions(actions1, actions2 []Action) bool

func MarshalXMLEntity

func MarshalXMLEntity(entity interface{}) ([]byte, error)

func NewChunkedReader

func NewChunkedReader(reader io.ReadCloser) io.ReadCloser

func NotIpAddressFunc

func NotIpAddressFunc(p *RequestParam, values ConditionValues) bool

func NumericEqualsFunc

func NumericEqualsFunc(p *RequestParam, value ConditionValues) bool

func NumericGreaterThanEqualsFunc

func NumericGreaterThanEqualsFunc(p *RequestParam, value ConditionValues) bool

func NumericGreaterThanFunc

func NumericGreaterThanFunc(p *RequestParam, value ConditionValues) bool

func NumericLessThanEqualsFunc

func NumericLessThanEqualsFunc(p *RequestParam, value ConditionValues) bool

func NumericLessThanFunc

func NumericLessThanFunc(p *RequestParam, value ConditionValues) bool

func NumericNotEqualsFunc

func NumericNotEqualsFunc(p *RequestParam, value ConditionValues) bool

func RequestIDFromRequest

func RequestIDFromRequest(r *http.Request) (id string)

func ServeInternalStaticErrorResponse

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

func StringEqualsFunc

func StringEqualsFunc(reqParam *RequestParam, storeCondVals ConditionValues) bool

func StringLikeFunc

func StringLikeFunc(reqParam *RequestParam, storeCondVals ConditionValues) bool

func StringNotEqualsFunc

func StringNotEqualsFunc(p *RequestParam, values ConditionValues) bool

func StringNotLikeFunc

func StringNotLikeFunc(p *RequestParam, values ConditionValues) bool

func TrimAwsPrefixKey

func TrimAwsPrefixKey(key string) string

func UnmarshalXMLEntity

func UnmarshalXMLEntity(bytes []byte, data interface{}) error

Types

type AccessControlList

type AccessControlList struct {
	Grants []Grant `xml:"Grant,omitempty"`
}

access control list

type AccessControlPolicy

type AccessControlPolicy struct {
	Xmlns string            `xml:"xmlns:xsi,attr"`
	Owner Owner             `xml:"Owner,omitempty"`
	Acl   AccessControlList `xml:"AccessControlList,omitempty"`
}

access control policy

func ParseACL

func ParseACL(bytes []byte, bucket string) (*AccessControlPolicy, error)

func (*AccessControlPolicy) IsAllowed

func (acp *AccessControlPolicy) IsAllowed(param *RequestParam) bool

func (*AccessControlPolicy) Marshal

func (acl *AccessControlPolicy) Marshal() ([]byte, error)

func (*AccessControlPolicy) SetBucketGrantACL

func (acp *AccessControlPolicy) SetBucketGrantACL(param *RequestParam, permission Permission)

func (*AccessControlPolicy) Validate

func (acp *AccessControlPolicy) Validate(bucket string) (bool, error)

type AclRole

type AclRole = string

type Arn

type Arn struct {
	// contains filtered or unexported fields
}

arn:partition:service:region:account-id:resource-id arn:partition:service:region:account-id:resource-type/resource-id arn:partition:service:region:account-id:resource-type:resource-id

type AuthType

type AuthType string

type BucketOwner

type BucketOwner struct {
	XMLName     xml.Name `xml:"Owner"`
	ID          string   `xml:"ID"`
	DisplayName string   `xml:"DisplayName"`
}

func NewBucketOwner

func NewBucketOwner(accessKey string) *BucketOwner

type CheckFuncs

type CheckFuncs func(p *RequestParam) bool

type CommonPrefix

type CommonPrefix struct {
	XMLName xml.Name `xml:"CommonPrefixes"`
	Prefix  string
}

type CompleteMultipartResult

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

type Condition

type Condition map[ConditionType]ConditionValues

type ConditionFunc

type ConditionFunc func(p *RequestParam, values ConditionValues) bool

type ConditionKey

type ConditionKey string

type ConditionType

type ConditionType string

type ConditionTypeSet

type ConditionTypeSet map[ConditionType]null

type Content

type Content struct {
	Key          string       `xml:"Key"`
	LastModified string       `xml:"LastModified"`
	ETag         string       `xml:"ETag"`
	Size         int          `xml:"Size"`
	StorageClass string       `xml:"StorageClass"`
	Owner        *BucketOwner `xml:"Owner,omitempty"`
}

type CopyObjectResult

type CopyObjectResult struct {
	XMLName      xml.Name `xml:"CopyObjectResult"`
	ETag         string   `xml:"ETag"`
	LastModified string   `xml:"LastModified"`
}

type CopyResult

type CopyResult struct {
	XMLName      xml.Name `xml:"CopyObjectResult"`
	LastModified string   `xml:"LastModified,omitempty"`
	ETag         string   `xml:"ETag,omitempty"`
}

type DeleteRequest

type DeleteRequest struct {
	XMLName xml.Name `xml:"Delete"`
	Objects []Object `xml:"Object"`
}

type DeleteResult

type DeleteResult struct {
	XMLName xml.Name  `json:"DeleteResult"`
	Deleted []Deleted `xml:"Deleted,omitempty"`
	Error   []Error   `xml:"Error,omitempty"`
}

type Deleted

type Deleted struct {
	XMLName               xml.Name `xml:"Deleted"`
	Key                   string   `xml:"Key"`
	VersionId             string   `xml:"VersionId,omitempty"`
	DeleteMarker          string   `xml:"DeleteMarker,omitempty"`
	DeleteMarkerVersionId string   `xml:"DeleteMarkerVersionId,omitempty"`
}

type DeletesResult

type DeletesResult struct {
	XMLName        xml.Name  `xml:"DeleteObjectsOutput"`
	DeletedObjects []Deleted `xml:"Deleted,omitempty"`
	DeletedErrors  []Error   `xml:"Error,omitempty"`
}

type Effect

type Effect string
const (
	Allow Effect = "Allow"
	Deny         = "Deny"
)

type Error

type Error struct {
	XMLName   xml.Name `xml:"Error"`
	Key       string   `xml:"Key"`
	VersionId string   `xml:"VersionId,omitempty"`
	Code      string   `xml:"Code,omitempty"`
	Message   string   `xml:"Message,omitempty"`
}

type ErrorCode

type ErrorCode struct {
	ErrorCode    string
	ErrorMessage string
	StatusCode   int
}

func (ErrorCode) ServeResponse

func (code ErrorCode) ServeResponse(w http.ResponseWriter, r *http.Request) error

type FSFileInfo

type FSFileInfo struct {
	Path       string
	Size       int64
	Mode       os.FileMode
	ModifyTime time.Time
	ETag       string
	Inode      uint64
}

type FSPart

type FSPart struct {
	PartNumber   int
	LastModified string
	ETag         string
	Size         int
}

type FSUpload

type FSUpload struct {
	Key          string
	UploadId     string
	StorageClass string
	Initiated    string
}

type GetBucketLocationOutput

type GetBucketLocationOutput struct {
	XMLName            xml.Name `xml:"GetBucketLocationOutput"`
	LocationConstraint string   `xml:"LocationConstraint"`
}

type Grant

type Grant struct {
	Grantee    Grantee    `xml:"Grantee,omitempty"`
	Permission Permission `xml:"Permission,omitempty"`
}

grant

func (*Grant) IsAllowed

func (g *Grant) IsAllowed(param *RequestParam) bool

func (Grant) Validate

func (g Grant) Validate() bool

type Grantee

type Grantee struct {
	Xmlns        string `xmlns:si,attr,omitempty`
	Xmlsi        string `xsi:type,attr,omitempty`
	Id           string `xml:"ID,omitempty"`
	URI          string `xml:"URI,omitempty"`
	Type         string `xml:"Type,omitempty"`
	DisplayName  string `xml:"DisplayName,omitempty"`
	EmailAddress string `xml:"EmailAddress,omitempty"`
}

grantee

type InitMultipartResult

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

type ListBucketRequestV1

type ListBucketRequestV1 struct {
	// contains filtered or unexported fields
}

type ListBucketRequestV2

type ListBucketRequestV2 struct {
	// contains filtered or unexported fields
}

type ListBucketResult

type ListBucketResult struct {
	XMLName        xml.Name        `xml:"ListBucketResults"`
	Bucket         string          `xml:"Name"`
	Prefix         string          `xml:"Prefix"`
	Marker         string          `xml:"Marker"`
	MaxKeys        int             `xml:"MaxKeys"`
	Delimiter      string          `xml:"Delimiter"`
	IsTruncated    bool            `xml:"IsTruncated"`
	NextMarker     string          `xml:"NextMarker"`
	Contents       []*Content      `xml:"Contents"`
	CommonPrefixes []*CommonPrefix `xml:"CommonPrefixes"`
}

type ListBucketResultV2

type ListBucketResultV2 struct {
	XMLName        xml.Name        `xml:"ListBucketResult"`
	Name           string          `xml:"Name"`
	Prefix         string          `xml:"Prefix,omitempty"`
	Token          string          `xml:"ContinuationToken,omitempty"`
	NextToken      string          `xml:"NextContinuationToken,omitempty"`
	KeyCount       uint64          `xml:"KeyCount"`
	MaxKeys        uint64          `xml:"MaxKeys"`
	Delimiter      string          `xml:"Delimiter,omitempty"`
	IsTruncated    bool            `xml:"IsTruncated,omitempty"`
	Contents       []*Content      `xml:"Contents"`
	CommonPrefixes []*CommonPrefix `xml:"CommonPrefixes"`
}

type ListPartsResult

type ListPartsResult struct {
	XMLName          xml.Name     `xml:"ListPartsResult"`
	Bucket           string       `xml:"Bucket"`
	Key              string       `xml:"Key"`
	UploadId         string       `xml:"UploadId"`
	Owner            *BucketOwner `xml:"Owner"`
	StorageClass     string       `xml:"StorageClass"`
	PartNumberMarker int          `xml:"PartNumberMarker"`
	NextMarker       int          `xml:"NextPartNumberMarker"`
	MaxParts         int          `xml:"MaxParts"`
	IsTruncated      bool         `xml:"IsTruncated"`
	Parts            []*Part      `xml:"Parts"`
}

type ListUploadsResult

type ListUploadsResult struct {
	XMLName            xml.Name        `xml:"ListMultipartUploadsResult"`
	Bucket             string          `xml:"Bucket"`
	KeyMarker          string          `xml:"KeyMarker"`
	UploadIdMarker     string          `xml:"UploadIdMarker"`
	NextKeyMarker      string          `xml:"NextKeyMarker"`
	NextUploadIdMarker string          `xml:"NextUploadIdMarker"`
	Delimiter          string          `xml:"Delimiter"`
	Prefix             string          `xml:"Prefix"`
	MaxUploads         int             `xml:"MaxUploads"`
	IsTruncated        bool            `xml:"IsTruncated"`
	Uploads            []*Upload       `xml:"Uploads"`
	CommonPrefixes     []*CommonPrefix `xml:"CommonPrefixes"`
}

type ListXAttrsResult

type ListXAttrsResult struct {
	XMLName xml.Name `xml:"ListXAttrsResult"`
	XAttrs  []*XAttr `xml:"XAttrs>XAttr"`
}

type MetaStore

type MetaStore interface {
}

type OSSMeta

type OSSMeta struct {
	// contains filtered or unexported fields
}

type OSSOperation

type OSSOperation string

type Object

type Object struct {
	Key       string `xml:"Key"`
	VersionId string `xml:"VersionId,omitempty"`
}

type ObjectNode

type ObjectNode struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *ObjectNode

func (*ObjectNode) Shutdown

func (o *ObjectNode) Shutdown()

func (*ObjectNode) Start

func (o *ObjectNode) Start(cfg *config.Config) (err error)

func (*ObjectNode) Sync

func (o *ObjectNode) Sync()

type Owner

type Owner struct {
	Id          string `xml:"ID"`
	DispalyName string `xml:"DisplayName"`
}

owner

type Part

type Part struct {
	XMLName      xml.Name `xml:"Part"`
	PartNumber   int      `xml:"PartNumber"`
	LastModified string   `xml:"LastModified"`
	ETag         string   `xml:"ETag"`
	Size         int      `xml:"Size"`
}

func NewParts

func NewParts(fsParts []*FSPart) []*Part

type Permission

type Permission string

grant permission

type Policy

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

func ParsePolicy

func ParsePolicy(r io.Reader, bucket string) (*Policy, error)

func (*Policy) IsAllowed

func (p *Policy) IsAllowed(params *RequestParam) bool

check policy is allowed for request https://docs.aws.amazon.com/zh_cn/IAM/latest/UserGuide/reference_policies_evaluation-logic.html 如果适用策略包含 Deny 语句,则请求会导致显式拒绝。 如果应用于请求的策略包含一个 Allow 语句和一个 Deny 语句,Deny 语句优先于 Allow 语句。将显式拒绝请求。 当没有适用的 Deny 语句但也没有适用的 Allow 语句时,会发生隐式拒绝。

func (Policy) Validate

func (p Policy) Validate(bucket string) (bool, error)

type PrefixMap

type PrefixMap map[string]struct{}

func (PrefixMap) AddPrefix

func (m PrefixMap) AddPrefix(prefix string)

func (PrefixMap) Prefixes

func (m PrefixMap) Prefixes() Prefixes

type Prefixes

type Prefixes []string

type Principal

type Principal map[string]StringSet

type PutXAttrRequest

type PutXAttrRequest struct {
	XMLName xml.Name `xml:"PutXAttrRequest"`
	XAttr   *XAttr   `xml:"XAttr"`
}

type RequestAuthInfo

type RequestAuthInfo struct {
	// contains filtered or unexported fields
}

type RequestParam

type RequestParam struct {
	// contains filtered or unexported fields
}

type Resource

type Resource string

type ResourceType

type ResourceType string

type StandardACL

type StandardACL string

type Statement

type Statement struct {
	Sid          string    `json:"Sid,omitempty"`
	Effect       Effect    `json:"Effect"`
	Principal    Principal `json:"Principal"`
	Actions      StringSet `json:"Action,omitempty"`
	NotActions   StringSet `json:"NotAction,omitempty"`
	Resources    StringSet `json:"Resource,omitempty"`
	NotResources StringSet `json:"NotResource,omitempty"`
	Condition    Condition `json:"Condition,omitempty"`
}

func (Statement) IsAllowed

func (s Statement) IsAllowed(p *RequestParam) bool

func (*Statement) Validate

func (s *Statement) Validate(bucket string) (bool, error)

type Store

type Store interface {
	Init(vm *volumeManager)
	Put(ns, obj, key string, data []byte) error
	Get(ns, obj, key string) (data []byte, err error)
	List(ns, obj string) (data [][]byte, err error)
	Delete(ns, obj, key string) error
}

MetaStore

type StringSet

type StringSet struct {
	// contains filtered or unexported fields
}

func (*StringSet) Contains

func (ss *StringSet) Contains(val string) bool

func (*StringSet) ContainsRegex

func (ss *StringSet) ContainsRegex(val string) bool

func (*StringSet) ContainsWild

func (ss *StringSet) ContainsWild(val string) bool

func (*StringSet) ContainsWithAny

func (ss *StringSet) ContainsWithAny(val string) bool

func (*StringSet) Empty

func (ss *StringSet) Empty() bool

func (*StringSet) Intersection

func (ss *StringSet) Intersection(set *StringSet) bool

func (StringSet) MarshalJSON

func (ss StringSet) MarshalJSON() ([]byte, error)

func (StringSet) String

func (ss StringSet) String() string

func (*StringSet) UnmarshalJSON

func (ss *StringSet) UnmarshalJSON(b []byte) error

type Tag

type Tag struct {
	Key   string `xml:"Key"`
	Value string `xml:"Value"`
}

type Tagging

type Tagging struct {
	XMLName xml.Name `xml:"Tagging"`
	TagSet  []*Tag   `xml:"TagSet>Tag"`
}

type Upload

type Upload struct {
	XMLName      xml.Name     `xml:"Upload"`
	Key          string       `xml:"Key"`
	UploadId     string       `xml:"UploadId"`
	StorageClass string       `xml:"StorageClass"`
	Initiated    string       `xml:"Initiated"`
	Owner        *BucketOwner `xml:"Owner"`
}

func NewUploads

func NewUploads(fsUploads []*FSUpload, accessKey string) []*Upload

type Volume

type Volume interface {
	OSSSecure() (accessKey, secretKey string)
	OSSMeta() *OSSMeta

	// ListFiles return an FileInfo slice of specified volume, like read dir for hole volume.
	// The result will be ordered by full path.
	ListFilesV1(request *ListBucketRequestV1) ([]*FSFileInfo, string, bool, []string, error)

	ListFilesV2(request *ListBucketRequestV2) ([]*FSFileInfo, uint64, string, bool, []string, error)

	// PutObject create file in specified volume with specified path.
	WriteFile(path string, reader io.Reader) (*FSFileInfo, error)

	// DeleteFile delete specified file from specified volume. If target is not exists then returns error.
	DeleteFile(path string) error

	FileInfo(path string) (*FSFileInfo, error)

	// operation about multipart uploads
	InitMultipart(path string) (multipartID string, err error)
	WritePart(path, multipartID string, partId uint16, reader io.Reader) (*FSFileInfo, error)
	ListParts(path, multipartID string, maxParts, partNumberMarker uint64) ([]*FSPart, uint64, bool, error)
	CompleteMultipart(path, multipartID string) (*FSFileInfo, error)
	AbortMultipart(path, multipartID string) error
	ListMultipartUploads(prefix, delimiter, keyMarker, uploadIdMarker string, maxUploads uint64) ([]*FSUpload, string, string, bool, []string, error)

	ReadFile(path string, writer io.Writer, offset, size uint64) error

	CopyFile(path, sourcePath string) (*FSFileInfo, error)

	SetXAttr(path string, key string, data []byte) error
	GetXAttr(path string, key string) (*proto.XAttrInfo, error)
	DeleteXAttr(path string, key string) error

	Close() error
}

type VolumeManager

type VolumeManager interface {
	Volume(volName string) (Volume, error)
	Release(volName string)
	GetStore() (Store, error)
	InitStore(s Store)
	Close()
}

func NewVolumeManager

func NewVolumeManager(masters []string) VolumeManager

type XAttr

type XAttr struct {
	Key   string `xml:"key"`
	Value string `xml:"Value"`
}

Jump to

Keyboard shortcuts

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