drive

package
Version: v0.0.0-...-5976ef8 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

This is a go lang package written for https://www.aliyundrive.com/

go lang implementation for calculating proof_code see aliyun-drive-fe/aliyun-drive/2.0.12-web/web/bundle.js

Index

Constants

View Source
const (
	FolderKind = "folder"
	FileKind   = "file"
	AnyKind    = "any"
)

Variables

This section is empty.

Functions

func A

func A(n int32, t int32, e int32, a int32, r int32, i int32, l int32) int32

func C

func C(n int32, t int32, e int32, a int32, r int32, i int32, l int32) int32

func CalcProofOffset

func CalcProofOffset(accessToken string, fileSize int64) int64

func CalcSha1

func CalcSha1(in *os.File) (*os.File, string, error)

func D

func D(n string) []int32

func F

func F(n string) string

func G

func G(n string) string

func H

func H(n string) string

func I

func I(n int32, t int32) int32

func L

func L(n int32, t int32, e int32, a int32, r int32, i int32, l int32) int32

func O

func O(n int32, t int32, e int32, a int32, r int32, o int32) int32

func P

func P(n []int32, t int32) []int32

func S

func S(n int32, t int32, e int32, a int32, r int32, i int32, l int32) int32

func U

func U(n []int32) string

Types

type AlbumInfo

type AlbumInfo struct {
	Data struct {
		DriveId string `json:"driveId"`
	} `json:"data"`
}

type Config

type Config struct {
	RefreshToken string
	IsAlbum      bool
	HttpClient   *http.Client
}

func (Config) String

func (config Config) String() string

type DownloadUrl

type DownloadUrl struct {
	Size       int64             `json:"size"`
	StreamsUrl map[string]string `json:"streams_url,omitempty"`
	Url        string            `json:"url"`
}

type Drive

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

func (*Drive) CalcProof

func (drive *Drive) CalcProof(fileSize int64, in *os.File) (*os.File, string, error)

func (*Drive) Copy

func (drive *Drive) Copy(ctx context.Context, node *Node, dstParent *Node, dstName string) error

https://help.aliyun.com/document_detail/175927.html#pdscopyfilerequest

func (*Drive) CreateFile

func (drive *Drive) CreateFile(ctx context.Context, fullPath string, size int64, in io.Reader, overwrite bool) (*Node, error)

func (*Drive) CreateFileWithProof

func (drive *Drive) CreateFileWithProof(ctx context.Context, fullPath string, size int64, in io.Reader, sha1Code string, proofCode string, overwrite bool) (*Node, error)

func (*Drive) CreateFolder

func (drive *Drive) CreateFolder(ctx context.Context, fullPath string) (*Node, error)

func (*Drive) List

func (drive *Drive) List(ctx context.Context, fullPath string) ([]Node, error)

func (*Drive) Move

func (drive *Drive) Move(ctx context.Context, node *Node, dstParent *Node, dstName string) error

func (*Drive) Open

func (drive *Drive) Open(ctx context.Context, node *Node, headers map[string]string) (io.ReadCloser, error)

func (*Drive) Remove

func (drive *Drive) Remove(ctx context.Context, node *Node) error

func (*Drive) Rename

func (drive *Drive) Rename(ctx context.Context, node *Node, newName string) error

func (*Drive) String

func (drive *Drive) String() string

type Fs

type Fs interface {
	Get(ctx context.Context, fullPath string, kind string) (*Node, error)
	List(ctx context.Context, fullPath string) ([]Node, error)
	CreateFolder(ctx context.Context, fullPath string) (*Node, error)
	Rename(ctx context.Context, node *Node, newName string) error
	Move(ctx context.Context, node *Node, dstParent *Node, dstName string) error
	Remove(ctx context.Context, node *Node) error
	Open(ctx context.Context, node *Node, headers map[string]string) (io.ReadCloser, error)
	CreateFile(ctx context.Context, fullPath string, size int64, in io.Reader, overwrite bool) (*Node, error)
	CalcProof(fileSize int64, in *os.File) (*os.File, string, error)
	CreateFileWithProof(ctx context.Context, fullPath string, size int64, in io.Reader, sha1Code string, proofCode string, overwrite bool) (*Node, error)
	Copy(ctx context.Context, node *Node, dstParent *Node, dstName string) error
}

func NewFs

func NewFs(ctx context.Context, config *Config) (Fs, error)

type ListNodes

type ListNodes struct {
	Items      []Node `json:"items"`
	NextMarker string `json:"next_marker"`
}

type Node

type Node struct {
	DownloadUrl string `json:"download_url,omitempty"`
	Type        string `json:"type"`                   // folder | file
	Hash        string `json:"content_hash,omitempty"` // sha1
	Name        string `json:"name"`
	NodeId      string `json:"file_id"`
	ParentId    string `json:"parent_file_id,omitempty"`
	Size        int64  `json:"size,omitempty"`
	Updated     string `json:"updated_at"`
}

func (*Node) GetName

func (n *Node) GetName() string

func (*Node) GetTime

func (n *Node) GetTime() (time.Time, error)

func (*Node) IsDirectory

func (n *Node) IsDirectory() bool

func (Node) String

func (n Node) String() string

type PartInfo

type PartInfo struct {
	UploadUrl string `json:"upload_url"`
}

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
}

type UploadResult

type UploadResult struct {
	PartInfoList []PartInfo `json:"part_info_list,omitempty"`
	FileId       string     `json:"file_id"`
	RapidUpload  bool       `json:"rapid_upload"`
	UploadId     string     `json:"upload_id"`
	FileName     string     `json:"file_name"`
}

type User

type User struct {
	DriveId string `json:"default_drive_id"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL