upyun

package
v3.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPartNum = 10000

	DefaultPartSize = minResumePutFileSize
)

Variables

This section is empty.

Functions

func IsNotExist

func IsNotExist(err error) bool

func IsNotExistedErr

func IsNotExistedErr(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 {
	FileName    string
	FileSize    int64
	ContentType string
	IsFileDir   bool
	IsEmptyDir  bool
	MD5         string
	Time        time.Time

	Meta map[string]string

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

func (FileInfo) IsDir

func (i FileInfo) IsDir() bool

abbreviation for Mode().IsFileDir()

func (FileInfo) ModTime

func (i FileInfo) ModTime() time.Time

modification time

func (FileInfo) Mode

func (i FileInfo) Mode() os.FileMode

file mode bits

func (FileInfo) Name

func (i FileInfo) Name() string

the full path of file

func (FileInfo) Size

func (i FileInfo) Size() int64

length in bytes for regular files; system-dependent for others

func (FileInfo) Sys

func (i FileInfo) Sys() interface{}

underlying data source (can return nil)

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
	PutMonitor        chan 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)

func (*UpYun) GetBody

func (up *UpYun) GetBody(config *GetObjectConfig) (io.ReadCloser, error)

func (*UpYun) GetInfo deprecated

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

Deprecated: Use Stat instead.

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 (up *UpYun) MakeFormAuth(policy string) string

func (*UpYun) MakeProcessAuth

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

func (*UpYun) MakePurgeAuth

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

func (*UpYun) MakeRESTAuth

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

func (*UpYun) MakeUnifiedAuth

func (up *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) Stat

func (up *UpYun) Stat(name string) (*FileInfo, error)

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()

func (*UpYun) Walk

func (up *UpYun) Walk(root string, walkFn filepath.WalkFunc) error

type UpYunConfig

type UpYunConfig struct {
	Bucket    string            `json:"bucket"`
	Operator  string            `json:"operator"`
	Password  string            `json:"password"`
	Secret    string            // deprecated
	Hosts     map[string]string `json:"hosts"`
	UserAgent string
	// Maximum number of retries before giving up.
	// Default is to not retry failed commands.
	MaxRetries      int    `json:"max_retries"`
	MinRetryBackoff string `json:"min_retry_backoff"`

	MaxRetryBackoff string `json:"max_retry_backoff"`
	// contains filtered or unexported fields
}

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