upyun

package
v3.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: MIT Imports: 23 Imported by: 18

Documentation

Index

Constants

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

	MaxListTries = 5
	MaxLimit     = 4096
	DefaultLimit = 256
)

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 BreakPointConfig added in v3.0.4

type BreakPointConfig struct {
	UploadID    string
	PartID      int // 待续传的 PartID
	PartSize    int64
	FileSize    int64
	FileModTime time.Time
	LastTime    time.Time
}

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 DisorderPart added in v3.0.4

type DisorderPart struct {
	ID           int64  `json:"id"`
	Size         int64  `json:"size"`
	LastModified int64  `json:"last_modified"`
	Etag         string `json:"etag"`
}

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 GetRequestConfig added in v3.0.4

type GetRequestConfig struct {
	Path    string
	Headers map[string]string
}

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 ListObjectsConfig added in v3.0.4

type ListObjectsConfig struct {
	Path         string            // 文件路径or文件夹路径
	Headers      map[string]string // 请求头
	Iter         string            // 下次遍历目录的开始位置,第一次不需要输入,之后每次返回结果时会返回当前结束的位置, 即下次开始的位置
	MaxListTries int               // 重试的次数最大值
	DescOrder    bool              // 正序or倒叙, 默认正序
	Limit        int               // 每次遍历的文件个数,默认256 最大值为4096
}

ListObjectsConfig list objects Config

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 MemoryRecorder added in v3.0.4

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

func (*MemoryRecorder) Delete added in v3.0.4

func (recorder *MemoryRecorder) Delete(path string)

func (*MemoryRecorder) Get added in v3.0.4

func (recorder *MemoryRecorder) Get(path string) *BreakPointConfig

func (*MemoryRecorder) Set added in v3.0.4

func (recorder *MemoryRecorder) Set(path string, breakpoint *BreakPointConfig)

func (*MemoryRecorder) TimedClearance added in v3.0.4

func (recorder *MemoryRecorder) TimedClearance()

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 Recorder added in v3.0.4

type Recorder interface {
	Set(path string, breakpoint *BreakPointConfig)

	Get(path string) *BreakPointConfig

	Delete(path string)

	TimedClearance()
}

type ResumeDisorderResult added in v3.0.4

type ResumeDisorderResult struct {
	Parts []*DisorderPart `json:"parts"`
}

type ResumeProcessResult added in v3.0.4

type ResumeProcessResult struct {
	UploadID     string
	Path         string
	NextPartSize int64
	NextPartID   int64
	Parts        []*DisorderPart
}

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

	Recorder
	// contains filtered or unexported fields
}

func NewUpYun

func NewUpYun(config *UpYunConfig) *UpYun

func (*UpYun) Close added in v3.0.4

func (up *UpYun) Close()

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)

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) GetRequest added in v3.0.4

func (up *UpYun) GetRequest(config *GetRequestConfig) (*http.Response, error)

GetRequest return response

func (*UpYun) GetResult

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

func (*UpYun) GetResumeProcess added in v3.0.4

func (up *UpYun) GetResumeProcess(path string) (*ResumeProcessResult, 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) ListObjects added in v3.0.4

func (up *UpYun) ListObjects(config *ListObjectsConfig) (fileInfos []*FileInfo, iter string, err 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) SetRecorder added in v3.0.4

func (up *UpYun) SetRecorder(recoder Recorder)

func (*UpYun) SetTimedTask added in v3.0.4

func (up *UpYun) SetTimedTask(task func())

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
	UseHTTP   bool
}

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