upyun

package
v3.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPartSize = 1024 * 1024
	MaxPartNum      = 10000
)

Variables

This section is empty.

Functions

func IsNotExist

func IsNotExist(err error) bool

func IsNotModified

func IsNotModified(err error) bool

func IsTooManyRequests

func IsTooManyRequests(err error) bool

Types

type CommitTasksConfig

type CommitTasksConfig struct {
	AppName   string
	Accept    string
	Source    string
	NotifyUrl string
	Tasks     []interface{}
}

type CompleteMultipartUploadConfig

type CompleteMultipartUploadConfig struct {
	Md5 string
}

type CopyObjectConfig

type CopyObjectConfig struct {
	SrcPath  string
	DestPath string
	Headers  map[string]string
}

type DeleteObjectConfig

type DeleteObjectConfig struct {
	Path   string
	Async  bool
	Folder bool // optional
}

type Error

type Error struct {
	Code       int    `json:"code"`
	Message    string `json:"msg"`
	RequestID  string `json:"id"`
	Operation  string
	StatusCode int
	Header     http.Header
	Body       []byte
}

func (*Error) Error

func (e *Error) Error() string

type FileInfo

type FileInfo struct {
	Name        string
	Size        int64
	ContentType string
	IsDir       bool
	IsEmptyDir  bool
	MD5         string
	Time        time.Time

	Meta map[string]string

	/* image information */
	ImgType   string
	ImgWidth  int64
	ImgHeight int64
	ImgFrames int64
}

type FormUploadConfig

type FormUploadConfig struct {
	LocalPath      string
	SaveKey        string
	ExpireAfterSec int64
	NotifyUrl      string
	Apps           []map[string]interface{}
	Options        map[string]interface{}
}

func (*FormUploadConfig) Format

func (config *FormUploadConfig) Format()

type FormUploadResp

type FormUploadResp struct {
	Code      int      `json:"code"`
	Msg       string   `json:"message"`
	Url       string   `json:"url"`
	Timestamp int64    `json:"time"`
	ImgWidth  int      `json:"image-width"`
	ImgHeight int      `json:"image-height"`
	ImgFrames int      `json:"image-frames"`
	ImgType   string   `json:"image-type"`
	Sign      string   `json:"sign"`
	Taskids   []string `json:"task_ids"`
}

type GetObjectConfig

type GetObjectConfig struct {
	Path string
	// Headers contains custom http header, like User-Agent.
	Headers   map[string]string
	LocalPath string
	Writer    io.Writer
}

GetObjectConfig provides a configuration to Get method.

type GetObjectsConfig

type GetObjectsConfig struct {
	Path           string
	Headers        map[string]string
	ObjectsChan    chan *FileInfo
	QuitChan       chan bool
	MaxListObjects int
	MaxListTries   int
	// MaxListLevel: depth of recursion
	MaxListLevel int
	// DescOrder:  whether list objects by desc-order
	DescOrder bool
	// contains filtered or unexported fields
}

GetObjectConfig provides a configuration to List method.

type InitMultipartUploadConfig

type InitMultipartUploadConfig struct {
	Path          string
	PartSize      int64
	ContentLength int64 // optional
	ContentType   string
	OrderUpload   bool
}

type InitMultipartUploadResult

type InitMultipartUploadResult struct {
	UploadID string
	Path     string
	PartSize int64
}

type JsonFileInfo

type JsonFileInfo struct {
	ContentType  string `json:"type"`
	Name         string `json:"name"`
	Length       int64  `json:"length"`
	LastModified int64  `json:"last_modified"`
}

type JsonFiles

type JsonFiles struct {
	Files []*JsonFileInfo `json:"files"`
	Iter  string          `json:"iter"`
}

type ListMultipartConfig

type ListMultipartConfig struct {
	Prefix string
	Limit  int64
}

type ListMultipartPartsConfig

type ListMultipartPartsConfig struct {
	BeginID int
}

type ListMultipartUploadResult

type ListMultipartUploadResult struct {
	Files []*MultipartUploadFile `json:"files"`
}

type ListUploadedPartsResult

type ListUploadedPartsResult struct {
	Parts []*MultipartUploadedPart `json:"parts"`
}

type LiveauditCancelTask

type LiveauditCancelTask struct {
	TaskId string
}

type LiveauditCreateTask

type LiveauditCreateTask struct {
	Source    string
	SaveAs    string
	NotifyUrl string
	Interval  string
	Resize    string
}

type ModifyMetadataConfig

type ModifyMetadataConfig struct {
	Path      string
	Operation string
	Headers   map[string]string
}

type MoveObjectConfig

type MoveObjectConfig struct {
	SrcPath  string
	DestPath string
	Headers  map[string]string
}

type MultipartUploadFile

type MultipartUploadFile struct {
	Key       string `json:"key"`
	UUID      string `json:"uuid"`
	Completed bool   `json:"completed"`
	CreatedAt int64  `json:"created_at"`
}

type MultipartUploadedPart

type MultipartUploadedPart struct {
	Etag string `json:"etag"`
	Size int64  `json:"size"`
	Id   int    `json:"id"`
}

type PurgeAuthConfig

type PurgeAuthConfig struct {
	PurgeList string
	DateStr   string
}

type PutObjectConfig

type PutObjectConfig struct {
	Path            string
	LocalPath       string
	Reader          io.Reader
	Headers         map[string]string
	UseMD5          bool
	UseResumeUpload bool
	// Append Api Deprecated
	// AppendContent     bool
	ResumePartSize    int64
	MaxResumePutTries int
}

PutObjectConfig provides a configuration to Put method.

type RESTAuthConfig

type RESTAuthConfig struct {
	Method    string
	Uri       string
	DateStr   string
	LengthStr string
}

type SyncCommonTask

type SyncCommonTask struct {
	Kwargs  map[string]interface{}
	TaskUri string
}

type UnifiedAuthConfig

type UnifiedAuthConfig struct {
	Method     string
	Uri        string
	DateStr    string
	Policy     string
	ContentMD5 string
}

type UpYun

type UpYun struct {
	UpYunConfig
	// contains filtered or unexported fields
}

func NewUpYun

func NewUpYun(config *UpYunConfig) *UpYun

func (*UpYun) CommitSyncTasks

func (up *UpYun) CommitSyncTasks(commitTask interface{}) (result map[string]interface{}, err error)

func (*UpYun) CommitTasks

func (up *UpYun) CommitTasks(config *CommitTasksConfig) (taskIds []string, err error)

func (*UpYun) CompleteMultipartUpload

func (up *UpYun) CompleteMultipartUpload(initResult *InitMultipartUploadResult, config *CompleteMultipartUploadConfig) error

func (*UpYun) Copy

func (up *UpYun) Copy(config *CopyObjectConfig) error

func (*UpYun) Delete

func (up *UpYun) Delete(config *DeleteObjectConfig) error

func (*UpYun) FormUpload

func (up *UpYun) FormUpload(config *FormUploadConfig) (*FormUploadResp, error)

func (*UpYun) Get

func (up *UpYun) Get(config *GetObjectConfig) (fInfo *FileInfo, err error)

TODO: maybe directory

func (*UpYun) GetInfo

func (up *UpYun) GetInfo(path string) (*FileInfo, error)

func (*UpYun) GetProgress

func (up *UpYun) GetProgress(taskIds []string) (result map[string]int, err error)

func (*UpYun) GetResult

func (up *UpYun) GetResult(taskIds []string) (result map[string]interface{}, err error)

func (*UpYun) InitMultipartUpload

func (up *UpYun) InitMultipartUpload(config *InitMultipartUploadConfig) (*InitMultipartUploadResult, error)

func (*UpYun) List

func (up *UpYun) List(config *GetObjectsConfig) error

func (*UpYun) ListMultipartParts

func (up *UpYun) ListMultipartParts(intiResult *InitMultipartUploadResult, config *ListMultipartPartsConfig) (*ListUploadedPartsResult, error)

func (*UpYun) ListMultipartUploads

func (up *UpYun) ListMultipartUploads(config *ListMultipartConfig) (*ListMultipartUploadResult, error)

func (*UpYun) MakeFormAuth

func (u *UpYun) MakeFormAuth(policy string) string

func (*UpYun) MakeProcessAuth

func (u *UpYun) MakeProcessAuth(kwargs map[string]string) string

func (*UpYun) MakePurgeAuth

func (u *UpYun) MakePurgeAuth(config *PurgeAuthConfig) string

func (*UpYun) MakeRESTAuth

func (u *UpYun) MakeRESTAuth(config *RESTAuthConfig) string

func (*UpYun) MakeUnifiedAuth

func (u *UpYun) MakeUnifiedAuth(config *UnifiedAuthConfig) string

func (*UpYun) Mkdir

func (up *UpYun) Mkdir(path string) error

func (*UpYun) ModifyMetadata

func (up *UpYun) ModifyMetadata(config *ModifyMetadataConfig) error

func (*UpYun) Move

func (up *UpYun) Move(config *MoveObjectConfig) error

func (*UpYun) Purge

func (up *UpYun) Purge(urls []string) (fails []string, err error)

TODO

func (*UpYun) Put

func (up *UpYun) Put(config *PutObjectConfig) (err error)

func (*UpYun) SetHTTPClient

func (up *UpYun) SetHTTPClient(httpc *http.Client)

func (*UpYun) UploadPart

func (up *UpYun) UploadPart(initResult *InitMultipartUploadResult, part *UploadPartConfig) error

func (*UpYun) Usage

func (up *UpYun) Usage() (n int64, err error)

func (*UpYun) UseDeprecatedApi

func (up *UpYun) UseDeprecatedApi()

type UpYunConfig

type UpYunConfig struct {
	Bucket    string
	Operator  string
	Password  string
	Secret    string // deprecated
	Hosts     map[string]string
	UserAgent string
}

type UpYunPutReader

type UpYunPutReader interface {
	Len() (n int)
	MD5() (ret string)
	Read([]byte) (n int, err error)
	Copyed() (n int)
}

type UploadPartConfig

type UploadPartConfig struct {
	Reader   io.Reader
	PartSize int64
	PartID   int
}

UploadFileConfig is multipart file upload config

Jump to

Keyboard shortcuts

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