tus_client

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MulanPSL-2.0 Imports: 16 Imported by: 2

README

说明

Tus v1.0.0协议客户端实现,参考自:tus resumable upload protocol

使用

go get gitee.com/ivfzhou/tus_client@latest
client := tus_client.NewClient("host")

// 并行分片上传
fileId, err := client.MultipleUploadFromFile(ctx, "your_file_path")

// 下载
err := client.DownloadToFile(ctx, "fileId", "to_file_path")

// 获取文件信息

联系

电邮:ivfzhou@126.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteRequest

type DeleteRequest struct {
	TusResumable string
	Location     string
}

type DeleteResult

type DeleteResult struct {
	HTTPStatus   int
	TusResumable string
}

type GetRequest

type GetRequest struct {
	TusResumable string
	Location     string
}

type GetResult

type GetResult struct {
	HTTPStatus    int
	TusResumable  string
	Body          io.ReadCloser
	ContentLength int
}

type HeadRequest

type HeadRequest struct {
	TusResumable string
	Location     string
}

type HeadResult

type HeadResult struct {
	HTTPStatus        int
	TusResumable      string
	UploadOffset      int
	UploadLength      int
	UploadMetadata    map[string]string
	UploadDeferLength bool
	UploadConcat      []string
}

type Option

type Option func(*Options)

func WithChunkSize

func WithChunkSize(chunkSize int) Option

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

func WithSchema

func WithSchema(schema string) Option

type Options

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

type OptionsResult

type OptionsResult struct {
	HTTPStatus           int
	TusExtension         []string
	TusResumable         string
	TusVersion           []string
	TusMaxSize           int
	TusChecksumAlgorithm []string
}

type PatchRequest

type PatchRequest struct {
	Location                string
	TusResumable            string
	UploadOffset            int
	Body                    []byte
	UploadChecksum          string
	UploadChecksumAlgorithm string
}

type PatchResult

type PatchResult struct {
	HTTPStatus    int
	TusResumable  string
	UploadOffset  int
	UploadExpires time.Time
}

type PostRequest

type PostRequest struct {
	TusResumable      string
	UploadMetadata    map[string]string
	UploadLength      int
	UploadDeferLength bool
	Body              []byte
	UploadConcat      string
}

type PostResult

type PostResult struct {
	HTTPStatus   int
	TusResumable string
	Location     string
	UploadOffset int
}

type TusClient

type TusClient interface {
	Options(context.Context) (*OptionsResult, error)
	Post(context.Context, *PostRequest) (*PostResult, error)
	Head(context.Context, *HeadRequest) (*HeadResult, error)
	Patch(context.Context, *PatchRequest) (*PatchResult, error)
	Delete(context.Context, *DeleteRequest) (*DeleteResult, error)
	Get(context.Context, *GetRequest) (*GetResult, error)
	MultipleUploadFromFile(ctx context.Context, filePath string) (location string, err error)
	MultipleUploadFromReader(ctx context.Context, r io.Reader) (location string, err error)
	DownloadToFile(ctx context.Context, location, dest string) error
	DownloadToWriter(ctx context.Context, location string, w io.Writer) error
}

func NewClient

func NewClient(host string, opts ...Option) TusClient

Jump to

Keyboard shortcuts

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