Documentation
¶
Index ¶
- Constants
- Variables
- func EscapeLFString(str string) string
- func EscapeXml(s string) string
- func NewSignature(content, accessKeySecret string) string
- type Bucket
- type CompleteMultipartUploadResult
- type DeleteObject
- type DeleteObjectVersionsResult
- type DeleteObjectsResult
- type DeletedKeyInfo
- type Error
- type InitiateMultipartUploadResult
- type ListObjectsResult
- type ListObjectsResultV2
- type NewBucketOptions
- type Object
- type ObjectProperties
- type Owner
- type RangeReader
- type ServiceError
- type Stat
- type UploadPart
- type UploadParts
Constants ¶
const ( Byte int64 = 1 << (iota * 10) KiByte MiByte GiByte TiByte PiByte EiByte )
size constant defined
const ( MaxRecvBytes = 16 << 20 // 16M MaxSendBytes = math.MaxInt32 )
const ( DefaultContentSha256 = "UNSIGNED-PAYLOAD" // for v4 signature OssContentSha256Key = "X-Oss-Content-Sha256" )
const (
MaxKeys = 1000
)
Variables ¶
var (
ErrNoSizeFromRange = errors.New("no size from range")
)
Functions ¶
func EscapeLFString ¶
func EscapeXml ¶
EscapeString writes to p the properly escaped XML equivalent of the plain text data s.
func NewSignature ¶
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)
}
func NewBucket ¶
func NewBucket(opts *NewBucketOptions) (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.
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 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 Object 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 ¶
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.
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)