huaweidrive

package
v1.74.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 31 Imported by: 0

README

api文档 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-public-info-0000001050159641 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-aboutget-0000001050151684 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filescopy-0000001050151696 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filescreate-0000001050151686 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filescreatecontent-0000001050151688 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filescreatemultipart-0000001050151694 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filescreateresume-0000001050151690 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesdelete-0000001050153647 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesemptyrecycle-0000001050151698 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesgetmetadata-0000001050153645 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesgetcontent-0000001050153651 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-fileslist-0000001050153649 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesresume-0000001050153643 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filessubscribe-0000001050153637 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesupdate-0000001050153639 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesupdatepatchcontent-0000001050151700 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesupdatepatchmultipart-0000001050153653 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesupdatepatchresume-0000001050153641 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesupdateputcontent-0000001050151702 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesupdateputmultipart-0000001050151704 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-filesupdateputresume-0000001050151692 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-thumbnailget-0000001050151706 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-changesgetstartcursor-0000001050153659 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-changeslist-0000001050151710 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-changessubscribe-0000001050151708 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-channelsstop-0000001050151712 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-commentscreate-0000001050151716 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-commentsdelete-0000001050151718 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-commentsget-0000001050153665 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-commentslist-0000001050151714 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-commentsupdate-0000001050153667 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-repliescreate-0000001050151722 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-repliesdelete-0000001050151724 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-repliesget-0000001050153671 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-replieslist-0000001050151720 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-repliesupdate-0000001050153673 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-smallthumbnailget-0000001050151726 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-commentsdelete-0000001050188702 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-commentsget-0000001050430911 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-historyversionsgetcontent-0000001050747405 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-commentslist-0000001050188698 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-commentsupdate-0000001050190853 https://developer.huawei.com/consumer/cn/doc/HMSCore-References/server-api-batchcallback-0000001050727110

Documentation

Overview

Package huaweidrive implements the Huawei Drive backend for rclone

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFs

func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error)

NewFs constructs an Fs from the path, container:path

Types

type Fs

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

Fs represents a remote Huawei Drive

func (*Fs) About

func (f *Fs) About(ctx context.Context) (usage *fs.Usage, err error)

About gets quota information

func (*Fs) ChangeNotify

func (f *Fs) ChangeNotify(ctx context.Context, notifyFunc func(string, fs.EntryType), pollIntervalChan <-chan time.Duration)

ChangeNotify calls the passed function with a path that has had changes. It polls the Huawei Drive Changes API at the given interval.

func (*Fs) CleanUp

func (f *Fs) CleanUp(ctx context.Context) error

CleanUp empties the trash

func (*Fs) Copy

func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object, error)

Copy src to this remote using server-side copy operations.

This is stored with the remote path given.

It returns the destination Object and a possible error.

Will only be called if src.Fs().Name() == f.Name().

If it isn't possible then return fs.ErrorCantCopy

func (*Fs) CreateDir

func (f *Fs) CreateDir(ctx context.Context, pathID, leaf string) (newID string, err error)

CreateDir makes a directory with pathID as parent and name leaf

func (*Fs) DirCacheFlush

func (f *Fs) DirCacheFlush()

DirCacheFlush resets the directory cache - used in testing as an optional interface

func (*Fs) DirMove

func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string) error

DirMove moves src, srcRemote to this remote at dstRemote using server-side move operations.

Will only be called if src.Fs().Name() == f.Name()

If it isn't possible then return fs.ErrorCantDirMove

If destination exists then return fs.ErrorDirExists

func (*Fs) Disconnect

func (f *Fs) Disconnect(ctx context.Context) error

Disconnect the current user by removing stored token

func (*Fs) Features

func (f *Fs) Features() *fs.Features

Features returns the optional features of this Fs

func (*Fs) FindLeaf

func (f *Fs) FindLeaf(ctx context.Context, pathID, leaf string) (pathIDOut string, found bool, err error)

FindLeaf finds a directory of name leaf in the folder with ID pathID

func (*Fs) Hashes

func (f *Fs) Hashes() hash.Set

Hashes returns the supported hash sets.

func (*Fs) List

func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err error)

List the objects and directories in dir into entries. The entries can be returned in any order but should be for a complete directory.

dir should be "" to list the root, and should not have trailing slashes.

This should return ErrDirNotFound if the directory isn't found.

func (*Fs) ListR

func (f *Fs) ListR(ctx context.Context, dir string, callback fs.ListRCallback) (err error)

ListR lists the objects and directories of the Fs starting from dir recursively into out.

dir should be "" to start from the root, and should not have trailing slashes.

This should return ErrDirNotFound if the directory isn't found.

It should call callback for each tranche of entries read. These need not be returned in any particular order. If callback returns an error then the listing will stop immediately.

Don't implement this unless you have a more efficient way of listing recursively that doing a directory traversal.

func (*Fs) Mkdir

func (f *Fs) Mkdir(ctx context.Context, dir string) error

Mkdir creates the container if it doesn't exist

func (*Fs) Move

func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object, error)

Move src to this remote using server-side move operations.

This is stored with the remote path given.

It returns the destination Object and a possible error.

Will only be called if src.Fs().Name() == f.Name().

If it isn't possible then return fs.ErrorCantMove

NOTE: Huawei Drive API has limitations with cross-directory moves: - Same-directory renames work perfectly - Cross-directory moves often fail silently (API returns success but file doesn't move) - We detect this by verifying the parentFolder after the API call - When detected, we return fs.ErrorCantMove to trigger rclone's copy+delete fallback

func (*Fs) Name

func (f *Fs) Name() string

Name of the remote (as passed into NewFs)

func (*Fs) NewObject

func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error)

NewObject finds the Object at remote. If it can't be found it returns the error fs.ErrorObjectNotFound.

func (*Fs) Precision

func (f *Fs) Precision() time.Duration

Precision return the precision of this Fs

func (*Fs) Purge

func (f *Fs) Purge(ctx context.Context, dir string) error

Purge deletes all the files in the directory

Optional interface: Only implement this if you have a way of deleting all the files quicker than just running Remove() on the result of List()

func (*Fs) Put

func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)

Put the object into the container

Copy the reader in to the new object which is returned.

The new object may have been created if an error is returned

func (*Fs) PutUnchecked

func (f *Fs) PutUnchecked(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)

PutUnchecked the object into the container

This will produce duplicates if we haven't checked that there is an existing object first.

Copy the reader in to the new object which is returned.

The new object may have been created if an error is returned.

func (*Fs) Rmdir

func (f *Fs) Rmdir(ctx context.Context, dir string) error

Rmdir deletes the root folder

Returns an error if it isn't empty

func (*Fs) Root

func (f *Fs) Root() string

Root of the remote (as passed into NewFs)

func (*Fs) String

func (f *Fs) String() string

String converts this Fs to a string

func (*Fs) UserInfo

func (f *Fs) UserInfo(ctx context.Context) (map[string]string, error)

UserInfo returns info about the connected user

type Object

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

Object describes a Huawei Drive object

func (*Object) Fs

func (o *Object) Fs() fs.Info

Fs returns the parent Fs

func (*Object) Hash

func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error)

Hash returns the SHA256 of the object

func (*Object) Metadata

func (o *Object) Metadata(ctx context.Context) (metadata fs.Metadata, err error)

Metadata returns metadata for an object

It should return nil if there is no Metadata

func (*Object) MimeType

func (o *Object) MimeType(ctx context.Context) string

MimeType returns the content type of the object if known, or "" if not

func (*Object) ModTime

func (o *Object) ModTime(ctx context.Context) time.Time

ModTime returns the modification time of the object

It attempts to read the objects mtime and if that isn't present the LastModified returned in the http headers

func (*Object) Open

func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error)

Open an object for read

func (*Object) Remote

func (o *Object) Remote() string

Remote returns the remote path

func (*Object) Remove

func (o *Object) Remove(ctx context.Context) error

Remove an object

func (*Object) SetMetadata

func (o *Object) SetMetadata(ctx context.Context, metadata fs.Metadata) error

SetMetadata sets metadata for an Object

It should return fs.ErrorNotImplemented if it can't set metadata

func (*Object) SetModTime

func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error

SetModTime sets the modification time of the local fs object

Huawei Drive API does not support setting modification times, so this always returns ErrorCantSetModTime.

func (*Object) Size

func (o *Object) Size() int64

Size returns the size of an object in bytes

func (*Object) Storable

func (o *Object) Storable() bool

Storable returns a boolean showing whether this object storable

func (*Object) String

func (o *Object) String() string

Return a string version

func (*Object) Update

func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error)

Update the object with the contents of the io.Reader, modTime and size

If existing is set then it updates the object rather than creating a new one.

The new object may have been created if an error is returned

type Options

type Options struct {
	RootFolderID string               `config:"root_folder_id"`
	ChunkSize    fs.SizeSuffix        `config:"chunk_size"`
	ListChunk    int                  `config:"list_chunk"`
	UploadCutoff fs.SizeSuffix        `config:"upload_cutoff"`
	Enc          encoder.MultiEncoder `config:"encoding"`
}

Options defines the configuration for this backend

type QueryFilter

type QueryFilter struct {
	Conditions []string
}

QueryFilter represents a Huawei Drive query filter

func NewQueryFilter

func NewQueryFilter() *QueryFilter

NewQueryFilter creates a new empty query filter

func (*QueryFilter) AddDirectlyRecycled

func (q *QueryFilter) AddDirectlyRecycled(directlyRecycled bool)

AddDirectlyRecycled adds a directly recycled status filter condition

func (*QueryFilter) AddEditedTimeRange

func (q *QueryFilter) AddEditedTimeRange(operator string, editedTime time.Time)

AddEditedTimeRange adds an edited time range filter condition

func (*QueryFilter) AddFavorite

func (q *QueryFilter) AddFavorite(favorite bool)

AddFavorite adds a favorite status filter condition

func (*QueryFilter) AddFileName

func (q *QueryFilter) AddFileName(fileName string)

AddFileName adds a file name filter condition

func (*QueryFilter) AddFileNameContains

func (q *QueryFilter) AddFileNameContains(fileName string)

AddFileNameContains adds a file name contains filter condition

func (*QueryFilter) AddMimeType

func (q *QueryFilter) AddMimeType(mimeType string)

AddMimeType adds a mime type filter condition

func (*QueryFilter) AddMimeTypeNot

func (q *QueryFilter) AddMimeTypeNot(mimeType string)

AddMimeTypeNot adds a negative mime type filter condition

func (*QueryFilter) AddParentFolder

func (q *QueryFilter) AddParentFolder(parentID string)

AddParentFolder adds a parent folder filter condition

func (*QueryFilter) AddRecycled

func (q *QueryFilter) AddRecycled(recycled bool)

AddRecycled adds a recycled status filter condition

func (*QueryFilter) String

func (q *QueryFilter) String() string

String returns the query filter as a string for the API

Directories

Path Synopsis
Package api provides types used by the Huawei Drive API.
Package api provides types used by the Huawei Drive API.

Jump to

Keyboard shortcuts

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