ossapi

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2015 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package ossapi is a golang implementation for aliyun's oss

Package ossapi is oss sdk of golang * * Author: CZ cz.theng@gmail.com

Index

Constants

View Source
const (
	// ErrNone is none error
	ErrNone = "None"
	//EAPI is SDK API's error
	EAPI = "OSSAPISDK"
	// EAccessDenied is oss's EAccessDenied
	EAccessDenied = "AccessDenied"
	// EBucketAlreadyExists is oss's EBucketAlreadyExists
	EBucketAlreadyExists = "BucketAlreadyExists"
	// EBucketNotEmpty is oss's EBucketNotEmpty
	EBucketNotEmpty = "BucketNotEmpty"
	// EEntityTooLarge is oss's EEntityTooLarge
	EEntityTooLarge = "EntityTooLarge"
	// EEntityTooSmall is oss's EEntityTooSmall
	EEntityTooSmall = "EntityTooSmall"
	// EFileGroupTooLarge is oss's EFileGroupTooLarge
	EFileGroupTooLarge = "FileGroupTooLarge"
	//EInvalidLinkName is oss's EInvalidLinkName
	EInvalidLinkName = "InvalidLinkName"
	// ELinkPartNotExist is oss's ELinkPartNotExist
	ELinkPartNotExist = "LinkPartNotExist"
	// EObjectLinkTooLarge is oss's EObjectLinkTooLarge
	EObjectLinkTooLarge = "ObjectLinkTooLarge"
	// EFieldItemTooLong is oss's EFieldItemTooLong
	EFieldItemTooLong = "FieldItemTooLong"
	//EFilePartInterity is oss's EFilePartInterity
	EFilePartInterity = "FilePartInterity"
	//EFilePartNotExist is oss's EFilePartNotExist
	EFilePartNotExist = "FilePartNotExist"
	//EFilePartStale is oss' EFilePartStale
	EFilePartStale = "FilePartStale"
	// EIncorrectNumberOfFilesInPOSTRequest is oss's EIncorrectNumberOfFilesInPOSTRequest
	EIncorrectNumberOfFilesInPOSTRequest = "IncorrectNumberOfFilesInPOSTRequest"
	// EInvalidArgument is oss's EInvalidArgument
	EInvalidArgument = "InvalidArgument"
	// EInvalidAccessKeyID is oss's EInvalidAccessKeyId
	EInvalidAccessKeyID = "InvalidAccessKeyId"
	// EInvalidBucketName is oss's EInvalidBucketName
	EInvalidBucketName = "InvalidBucketName"
	//EInvalidDigest is oss's EInvalidDigest
	EInvalidDigest = "InvalidDigest"
	//EInvalidEncryptionAlgorithmError is oss's EInvalidEncryptionAlgorithmError
	EInvalidEncryptionAlgorithmError = "InvalidEncryptionAlgorithmError"
	//EInvalidObjectName is oss' EInvalidObjectName
	EInvalidObjectName = "InvalidObjectName"
	// EInvalidPart is oss's EInvalidPart
	EInvalidPart = "InvalidPart"
	// EInvalidPartOrder is oss's EInvalidPartOrder
	EInvalidPartOrder = "InvalidPartOrder"
	// EInvalidPolicyDocument is oss's EInvalidPolicyDocument
	EInvalidPolicyDocument = "InvalidPolicyDocument"
	// EInvalidTargetBucketForLogging is oss's EInvalidTargetBucketForLogging
	EInvalidTargetBucketForLogging = "InvalidTargetBucketForLogging"
	// EInternalError is oss's EInternalError
	EInternalError = "InternalError"
	// EMalformedXML is oss's EMalformedXML
	EMalformedXML = "MalformedXML"
	// EMalformedPOSTRequest is oss's EMalformedPOSTRequest
	EMalformedPOSTRequest = "MalformedPOSTRequest"
	// EMaxPOSTPreDataLengthExceededError is oss's EMaxPOSTPreDataLengthExceededError
	EMaxPOSTPreDataLengthExceededError = "MaxPOSTPreDataLengthExceededError"
	//EMethodNotAllowed is oss's EMethodNotAllowed
	EMethodNotAllowed = "MethodNotAllowed"
	//EMissingArgument is oss's EMissingArgument
	EMissingArgument = "MissingArgument"
	// EMissingContentLength is oss's EMissingContentLength
	EMissingContentLength = "MissingContentLength"
	// ENoSuchBucket is oss's ENoSuchBucket
	ENoSuchBucket = "NoSuchBucket"
	// ENoSuchKey is oss's ENoSuchKey
	ENoSuchKey = "NoSuchKey"
	// ENoSuchUpload is oss's ENoSuchUpload
	ENoSuchUpload = "NoSuchUpload"
	// ENotImplemented is oss's ENotImplemented
	ENotImplemented = "NotImplemented"
	//EPreconditionFailed is oss's EPreconditionFailed
	EPreconditionFailed = "PreconditionFailed"
	//ERequestTimeTooSkewed is oss's ERequestTimeTooSkewed
	ERequestTimeTooSkewed = "RequestTimeTooSkewed"
	//ERequestTimeout is oss's ERequestTimeout
	ERequestTimeout = "RequestTimeout"
	// ERequestIsNotMultiPartContent is oss's ERequestIsNotMultiPartContent
	ERequestIsNotMultiPartContent = "RequestIsNotMultiPartContent"
	// ESignatureDoesNotMatch is oss's ESignatureDoesNotMatch
	ESignatureDoesNotMatch = "SignatureDoesNotMatch"
	// ETooManyBuckets is oss's ETooManyBuckets
	ETooManyBuckets = "TooManyBuckets"
)
View Source
const (
	// DateFmt is format date
	DateFmt = "Mon, 02 Jan 2006 15:04:05 GMT"
)

Variables

View Source
var (
	//ErrSUCC is none error
	ErrSUCC = errors.New("Success!")
	//ErrFAIL is all fail error
	ErrFAIL = errors.New("HTTP Request Failed(4xx/5xx)")
	// ErrUNKNOWN is other errors
	ErrUNKNOWN = errors.New("HTTP Request With Unknown Status (NOT 2xx/4xx/5xx)")
	//ErrARG is args error such as nil
	ErrARG = errors.New("Invalied Argument!")
)
View Source
var (
	// OSSAPIError is OSSAPI SDK's Error
	OSSAPIError = &Error{ErrNo: EAPI,
		ErrMsg:       "OSSAPI SDK's Inner Error,You Can Find More Details In Log Files",
		ErrDetailMsg: "OSSAPI SDK's Inner Error,You Can Find More Details In Log Files"}
	// ArgError is args' error such as nil
	ArgError = &Error{ErrNo: EAPI,
		ErrMsg:       "Argument Error.Please Check Your Argment Such as nil",
		ErrDetailMsg: "Argument Error.Please Check Your Argment Such as nil"}
)
View Source
var Logger *log.Logger

LogCat

Functions

func Base64AndHmacSha1

func Base64AndHmacSha1(key, data []byte) (encStr string, err error)

Base64AndHmacSha1 caculate base64 and sha

func Base64AndMd5

func Base64AndMd5(data []byte) (encStr string, err error)

Base64AndMd5 caclute Base64 and md5

func Init

func Init(ID string, secret string) error

Init ossapi with Access Key's ID and secret @param ID : Access Key's ID @param secret : Access Key's secret

func Version

func Version() string

Version show OSSAPI's verison

Types

type Error

type Error struct {
	// XMLName is XML need
	XMLName xml.Name `xml:"Error"`
	//ErrNo is error code
	ErrNo string `xml:"Code"`
	// ErrMsg is brief error
	ErrMsg string `xml:"Message"`
	// HTTPStatus is http response
	HTTPStatus int
	// ErrDetailMsg is Detail message
	ErrDetailMsg string
}

Error is ossapi's Error type

func (Error) Error

func (e Error) Error() string

type Request

type Request struct {
	Host      string
	Path      string
	Date      string
	Method    string
	CntType   string
	Resource  string
	SubRes    []string
	Override  map[string]string
	XOSSes    map[string]string
	Body      []byte
	ExtHeader map[string]string
	RspHeader map[string]string

	HTTPReq *http.Request
}

Request represent a request

func (*Request) AddXOSS

func (req *Request) AddXOSS(key string, value string)

AddXOSS add x-oss

func (*Request) Auth

func (req *Request) Auth() (authStr string, err error)

Auth do authorize

func (*Request) Send

func (req *Request) Send() (rsp *Response, err error)

Send do sent request

func (*Request) Signature

func (req *Request) Signature() (sig string, err error)

Signature calculate Signature

type Response

type Response struct {
	Result  error
	HTTPRsp *http.Response
}

Response to Request

type Tag

type Tag struct {
	RequestID string
	ETag      string
	Date      string
	Server    string
}

Tag Info for a Response

Directories

Path Synopsis
Package bucket is for buckets * * Author: CZ cz.theng@gmail.com Package bucket is for buckets
Package bucket is for buckets * * Author: CZ cz.theng@gmail.com Package bucket is for buckets
Package cors is for cors * * Author: CZ cz.theng@gmail.com * CORS allow remote domain to access resources.
Package cors is for cors * * Author: CZ cz.theng@gmail.com * CORS allow remote domain to access resources.
Package log is a wraper for log Package log is a logger wraper * * Author: CZ cz.theng@gmail.com
Package log is a wraper for log Package log is a logger wraper * * Author: CZ cz.theng@gmail.com
Package mupload is for mupload * * Author: CZ cz.theng@gmail.com
Package mupload is for mupload * * Author: CZ cz.theng@gmail.com
Package object is for object * * Author: CZ cz.theng@gmail.com
Package object is for object * * Author: CZ cz.theng@gmail.com

Jump to

Keyboard shortcuts

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