dropbox

package
v0.0.0-...-325f451 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Token string
	*http.Client
}

Client gives access to the Dropbox API

func NewClient

func NewClient(cl Client) (Client, error)

NewClient returns a fully created Client value

func (Client) AsFS

func (c Client) AsFS(ctx context.Context) FS

func (Client) Create

func (cl Client) Create(up UploadParams, body io.Reader) error

Create writes the body to path.

func (Client) Delete

func (cl Client) Delete(path string) error

Delete a file or folder. Official docs are at https://www.dropbox.com/developers/documentation/http/documentation#files-delete

func (Client) Download

func (cl Client) Download(path string) ([]byte, error)

Download a file

func (Client) GetMetadata

func (cl Client) GetMetadata(p GetMetadataParams) (Metadata, error)

GetMetadata gets metadata for a file or directory.

func (Client) ListFolder

func (cl Client) ListFolder(p ListFolderParams) (ListFolderResult, error)

func (Client) ListFolderContinue

func (cl Client) ListFolderContinue(cursor string) (ListFolderResult, error)

func (Client) ListFolderLongPoll

func (cl Client) ListFolderLongPoll(ctx context.Context, cursor string, timeout int) (bool, int, error)

func (Client) Longpoll

func (db Client) Longpoll(ctx context.Context, dir string, ch chan<- []Metadata)

Longpoll signals changes in dir by sending on ch.

type DropboxDirEntry

type DropboxDirEntry struct {
	Metadata
	io.Reader
	// contains filtered or unexported fields
}

func (*DropboxDirEntry) Close

func (e *DropboxDirEntry) Close() error

func (*DropboxDirEntry) Info

func (e *DropboxDirEntry) Info() (fs.FileInfo, error)

func (*DropboxDirEntry) IsDir

func (e *DropboxDirEntry) IsDir() bool

func (*DropboxDirEntry) ModTime

func (e *DropboxDirEntry) ModTime() time.Time

func (*DropboxDirEntry) Mode

func (e *DropboxDirEntry) Mode() fs.FileMode

func (*DropboxDirEntry) Name

func (e *DropboxDirEntry) Name() string

func (*DropboxDirEntry) Read

func (e *DropboxDirEntry) Read(b []byte) (int, error)

func (*DropboxDirEntry) ReadDir

func (e *DropboxDirEntry) ReadDir(n int) ([]fs.DirEntry, error)

func (*DropboxDirEntry) Size

func (e *DropboxDirEntry) Size() int64

func (*DropboxDirEntry) Stat

func (e *DropboxDirEntry) Stat() (fs.FileInfo, error)

func (*DropboxDirEntry) Sys

func (e *DropboxDirEntry) Sys() interface{}

func (*DropboxDirEntry) Type

func (e *DropboxDirEntry) Type() fs.FileMode

type FS

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

func (FS) Open

func (f FS) Open(name string) (fs.File, error)

func (FS) ReadDir

func (f FS) ReadDir(name string) ([]fs.DirEntry, error)

func (FS) ReadFile

func (f FS) ReadFile(name string) ([]byte, error)

func (FS) Remove

func (f FS) Remove(name string) error

func (FS) Stat

func (f FS) Stat(name string) (fs.FileInfo, error)

func (FS) Sub

func (f FS) Sub(dir string) (fs.FS, error)

func (FS) Watch

func (f FS) Watch(ctx context.Context, dir string) (chan []fsnotify.Event, error)

func (FS) WriteFile

func (f FS) WriteFile(name string, contents []byte, _ fs.FileMode) error

type GetMetadataParams

type GetMetadataParams struct {
	Path string `json:"path"`

	IncludeMediaInfo                bool `json:"include_media_info,omitempty"`
	IncludeDeleted                  bool `json:"include_deleted,omitempty"`
	IncludeHasExplicitSharedMembers bool `json:"include_has_explicit_shared_members,omitempty"`

	IncludePropertyGroups []string `json:"include_property_groups,omitempty"`
}

GetMetadataParams maps to the parameters to get-metadata, documented here: https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata

type ListFolderParams

type ListFolderParams struct {
	Path string `json:"path"`

	Recursive                       bool   `json:"recursive"`
	IncludeMediaInfo                bool   `json:"include_media_info"`
	IncludeDeleted                  bool   `json:"include_deleted"`
	IncludeHasExplicitSharedMembers bool   `json:"include_has_explicit_shared_members"`
	IncludeMountedFolders           bool   `json:"include_mounted_folders"`
	IncludeNonDownloadableFiles     bool   `json:"include_non_downloadable_files"`
	Limit                           uint32 `json:"limit,omitempty"`
}

ListFolderParams docs are at https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder

type ListFolderResult

type ListFolderResult struct {
	Entries []Metadata `json:"entries"`
	Cursor  string     `json:"cursor"`
	HasMore bool       `json:"has_more"`
}

type Metadata

type Metadata struct {
	Tag            string `json:".tag"`
	Name           string `json:"name"`
	ID             string `json:"id"`
	ClientModified string `json:"client_modified"` // could be time.Time
	ServerModified string `json:"server_modified"` // could be time.Time
	Rev            string `json:"rev"`
	Size           int    `json:"size"`
	PathLower      string `json:"path_lower"`
	PathDisplay    string `json:"path_display"`
	SharingInfo    struct {
		ParentSharedFolderID string `json:"parent_shared_folder_id"`
		ModifiedBy           string `json:"modified_by"`
		ReadOnly             bool   `json:"read_only"`
		TraverseOnly         bool   `json:"traverse_only"`
		NoAccess             bool   `json:"no_access"`
	} `json:"sharing_info"`
	IsDownloadable bool `json:"is_downloadable"`
	PropertyGroups []struct {
		TemplateID string `json:"template_id"`
		Fields     []struct {
			Name  string `json:"name"`
			Value string `json:"value"`
		}
	} `json:"property_groups"`
	HasExplicitSharedMembers bool   `json:"has_explicit_shared_members"`
	ContentHash              string `json:"content_hash"`
	FileLockInfo             struct {
		IsLockholder   bool   `json:"is_lockholder"`
		LockholderName string `json:"lockholder_name"`
		Created        string `json:"created"` // could be time.Time
	} `json:"file_lock_info"`
}

Metadata is defined at https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder

type UploadParams

type UploadParams struct {
	Path       string `json:"path"`
	Autorename bool   `json:"autorename,omitempty"`

	Mode string `json:"mode,omitempty"`
}

UploadParams maps to the parameters to file-upload, documented here: https://www.dropbox.com/developers/documentation/http/documentation#files-upload

Jump to

Keyboard shortcuts

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