oss

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte int64 = 1 << (iota * 10)
	KiByte
	MiByte
	GiByte
	TiByte
	PiByte
	EiByte
)

size constant defined

View Source
const (
	MaxRecvBytes = 16 << 20 // 16M
	MaxSendBytes = math.MaxInt32
)
View Source
const (
	DefaultContentSha256 = "UNSIGNED-PAYLOAD" // for v4 signature
	OssContentSha256Key  = "X-Oss-Content-Sha256"
)
View Source
const (
	MaxKeys = 1000
)

Variables

View Source
var (
	ErrNoSizeFromRange = errors.New("no size from range")
)

Functions

func EscapeLFString

func EscapeLFString(str string) string

func EscapeXml

func EscapeXml(s string) string

EscapeString writes to p the properly escaped XML equivalent of the plain text data s.

func NewSignature

func NewSignature(content, accessKeySecret string) string

NewSignature creates signature for string following Aliyun rules

Types

type Bucket

type Bucket interface {
	Stat(ctx context.Context, resourcePath string) (*Stat, error)
	Open(ctx context.Context, resourcePath string, start, length int64) (RangeReader, error)
	Delete(ctx context.Context, resourcePath string) error
	Put(ctx context.Context, resourcePath string, r io.Reader, mime string) error
	StartUpload(ctx context.Context, resourcePath, filePath string, mime string) error
	// LinearUpload: Aliyun oss currently has a 5GB file upload limit, so when the OSS object exceeds 5GB, we use the MultipartUpload mechanism to upload. However,
	// please note that due to network failures or other problems, large file uploads are prone to failure, and LFS is currently not working well. scheme to solve this problem.
	LinearUpload(ctx context.Context, resourcePath string, r io.Reader, size int64, mime string) error
	DeleteMultipleObjects(ctx context.Context, objectKeys []string) error
	ListObjects(ctx context.Context, prefix, continuationToken string) ([]*Object, string, error)
	Sharing(ctx context.Context, resourcePath string, expiresAt int64) string
}

func NewBucket

func NewBucket(opts *NewBucketOptions) (Bucket, error)

func NewGscBucket

func NewGscBucket(ctx context.Context, credentialsJSON []byte, ossBucketName string) (Bucket, error)

func NewS3Bucket

func NewS3Bucket(ctx context.Context, s3Region, s3AccessKeyID, s3AccessKeySecret, s3BucketName string, partSize int64) (Bucket, error)

type CompleteMultipartUploadResult

type CompleteMultipartUploadResult struct {
	XMLName  xml.Name `xml:"CompleteMultipartUploadResult"`
	Location string   `xml:"Location"` // Object URL
	Bucket   string   `xml:"Bucket"`   // Bucket name
	ETag     string   `xml:"ETag"`     // Object ETag
	Key      string   `xml:"Key"`      // Object name
}

CompleteMultipartUploadResult defines result object of CompleteMultipartUploadRequest

type DeleteObject

type DeleteObject struct {
	XMLName   xml.Name `xml:"Object"`
	Key       string   `xml:"Key"`                 // Object name
	VersionId string   `xml:"VersionId,omitempty"` // Object VersionId
}

DeleteObject defines the struct for deleting object

type DeleteObjectVersionsResult

type DeleteObjectVersionsResult struct {
	XMLName              xml.Name         `xml:"DeleteResult"`
	DeletedObjectsDetail []DeletedKeyInfo `xml:"Deleted"` // Deleted object detail info
}

type DeleteObjectsResult

type DeleteObjectsResult struct {
	XMLName        xml.Name
	DeletedObjects []string // Deleted object key list
}

DeleteObjectsResult defines result of DeleteObjects request

type DeletedKeyInfo

type DeletedKeyInfo struct {
	XMLName               xml.Name `xml:"Deleted"`
	Key                   string   `xml:"Key"`                   // Object key
	VersionId             string   `xml:"VersionId"`             // VersionId
	DeleteMarker          bool     `xml:"DeleteMarker"`          // Object DeleteMarker
	DeleteMarkerVersionId string   `xml:"DeleteMarkerVersionId"` // Object DeleteMarkerVersionId
}

DeletedKeyInfo defines object delete info

type Error

type Error struct {
	StatusCode int    // HTTP status code (200, 403, ...)
	Code       string // OSS error code ("UnsupportedOperation", ...)
	Message    string // The human-oriented error message
	BucketName string
	RequestId  string
	HostId     string
}

Error represents an error in an operation with OSS.

func (*Error) Error

func (e *Error) Error() string

type InitiateMultipartUploadResult

type InitiateMultipartUploadResult struct {
	XMLName  xml.Name `xml:"InitiateMultipartUploadResult"`
	Bucket   string   `xml:"Bucket"`   // Bucket name
	Key      string   `xml:"Key"`      // Object name to upload
	UploadID string   `xml:"UploadId"` // Generated UploadId
}

InitiateMultipartUploadResult defines result of InitiateMultipartUpload request

type ListObjectsResult

type ListObjectsResult struct {
	XMLName        xml.Name           `xml:"ListBucketResult"`
	Prefix         string             `xml:"Prefix"`                // The object prefix
	Marker         string             `xml:"Marker"`                // The marker filter.
	MaxKeys        int                `xml:"MaxKeys"`               // Max keys to return
	Delimiter      string             `xml:"Delimiter"`             // The delimiter for grouping objects' name
	IsTruncated    bool               `xml:"IsTruncated"`           // Flag indicates if all results are returned (when it's false)
	NextMarker     string             `xml:"NextMarker"`            // The start point of the next query
	Objects        []ObjectProperties `xml:"Contents"`              // Object list
	CommonPrefixes []string           `xml:"CommonPrefixes>Prefix"` // You can think of commonprefixes as "folders" whose names end with the delimiter
}

ListObjectsResult defines the result from ListObjects request

type ListObjectsResultV2

type ListObjectsResultV2 struct {
	XMLName               xml.Name           `xml:"ListBucketResult"`
	Prefix                string             `xml:"Prefix"`                // The object prefix
	StartAfter            string             `xml:"StartAfter"`            // the input StartAfter
	ContinuationToken     string             `xml:"ContinuationToken"`     // the input ContinuationToken
	MaxKeys               int                `xml:"MaxKeys"`               // Max keys to return
	Delimiter             string             `xml:"Delimiter"`             // The delimiter for grouping objects' name
	IsTruncated           bool               `xml:"IsTruncated"`           // Flag indicates if all results are returned (when it's false)
	NextContinuationToken string             `xml:"NextContinuationToken"` // The start point of the next NextContinuationToken
	Objects               []ObjectProperties `xml:"Contents"`              // Object list
	CommonPrefixes        []string           `xml:"CommonPrefixes>Prefix"` // You can think of commonprefixes as "folders" whose names end with the delimiter
}

ListObjectsResultV2 defines the result from ListObjectsV2 request

type NewBucketOptions

type NewBucketOptions struct {
	Endpoint        string
	SharedEndpoint  string
	Bucket          string
	AccessKeyID     string
	AccessKeySecret string
	Product         string
	Region          string
	PartSize        int64
}

type Object

type Object struct {
	Key  string `json:"key"`
	Size int64  `json:"size"`
	ETag string `json:"etag"`
}

type ObjectProperties

type ObjectProperties struct {
	XMLName      xml.Name  `xml:"Contents"`
	Key          string    `xml:"Key"`                   // Object key
	Type         string    `xml:"Type"`                  // Object type
	Size         int64     `xml:"Size"`                  // Object size
	ETag         string    `xml:"ETag"`                  // Object ETag
	Owner        Owner     `xml:"Owner"`                 // Object owner information
	LastModified time.Time `xml:"LastModified"`          // Object last modified time
	StorageClass string    `xml:"StorageClass"`          // Object storage class (Standard, IA, Archive)
	RestoreInfo  string    `xml:"RestoreInfo,omitempty"` // Object restoreInfo
}

ObjectProperties defines Objecct properties

type Owner

type Owner struct {
	XMLName     xml.Name `xml:"Owner"`
	ID          string   `xml:"ID"`          // Owner ID
	DisplayName string   `xml:"DisplayName"` // Owner's display name
}

Owner defines Bucket/Object's owner

type RangeReader

type RangeReader interface {
	io.Reader
	io.Closer
	Size() int64
	Range() string
}

func NewRangeReader

func NewRangeReader(rc io.ReadCloser, size int64, hdr string) RangeReader

type ServiceError

type ServiceError struct {
	XMLName    xml.Name `xml:"Error"`
	Code       string   `xml:"Code"`      // The error code returned from OSS to the caller
	Message    string   `xml:"Message"`   // The detail error message from OSS
	RequestID  string   `xml:"RequestId"` // The UUID used to uniquely identify the request
	HostID     string   `xml:"HostId"`    // The OSS server cluster's Id
	Endpoint   string   `xml:"Endpoint"`
	Ec         string   `xml:"EC"`
	RawMessage string   // The raw messages from OSS
	StatusCode int      // HTTP status code

}

ServiceError contains fields of the error response from Oss Service REST API.

func (*ServiceError) Error

func (e *ServiceError) Error() string

Error implements interface error

type Stat

type Stat struct {
	Size  int64
	Mime  string
	Crc64 string
}

type UploadPart

type UploadPart struct {
	XMLName    xml.Name `xml:"Part"`
	PartNumber int      `xml:"PartNumber"` // Part number
	ETag       string   `xml:"ETag"`       // ETag value of the part's data
}

UploadPart defines the upload/copy part

type UploadParts

type UploadParts []UploadPart

func (UploadParts) Len

func (slice UploadParts) Len() int

func (UploadParts) Less

func (slice UploadParts) Less(i, j int) bool

func (UploadParts) Swap

func (slice UploadParts) Swap(i, j int)

Jump to

Keyboard shortcuts

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