dropy

package module
v0.0.0-...-8059af3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 7 Imported by: 0

README

GoDoc Build Status

Dropy

High level Dropbox v2 client for Go built on top of go-dropbox.

Example

token := os.Getenv("DROPBOX_ACCESS_TOKEN")
client := dropy.New(dropbox.New(dropbox.NewConfig(token)))

client.Upload("/demo.txt", strings.NewReader("Hello World"))
io.Copy(os.Stdout, client.Open("/demo.txt"))

Testing

To manually run tests use the test account access token:

$ export DROPBOX_ACCESS_TOKEN=oENFkq_oIVAAAAAAAAAABqI2Nor2e9_ORA3oAZDQexMgJocCQX4aOFXZuDc1t-Sx
$ go test -v

License

MIT

Documentation

Overview

Package dropy implements a higher-level Dropbox API on top of go-dropbox.

Example

Upload and read a file.

token := env.MustGet("DROPBOX_ACCESS_TOKEN")
client := dropy.New(dropbox.New(dropbox.NewConfig(token)))

client.Upload("/demo.txt", strings.NewReader("Hello World"))
io.Copy(os.Stdout, client.Open("/demo.txt"))
Output:

Hello World

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*dropbox.Client
}

Client wraps dropbox.Client to provide higher level sugar.

func New

func New(d *dropbox.Client) *Client

New client.

func (*Client) Copy

func (c *Client) Copy(src, dst string) error

Copy file from `src` to `dst`.

func (*Client) Delete

func (c *Client) Delete(name string) error

Delete file `name`.

func (*Client) Download

func (c *Client) Download(name string) (io.ReadCloser, error)

Download returns the contents of `name`.

func (*Client) List

func (c *Client) List(name string) ([]os.FileInfo, error)

List returns all entries in dir `name`.

func (*Client) ListFiles

func (c *Client) ListFiles(name string) ([]os.FileInfo, error)

ListFiles returns all files in dir `name`.

func (*Client) ListFilter

func (c *Client) ListFilter(name string, filter func(info os.FileInfo) bool) (ret []os.FileInfo, err error)

ListFilter returns all entries in dir `name` filtered by `filter`.

func (*Client) ListFolders

func (c *Client) ListFolders(name string) ([]os.FileInfo, error)

ListFolders returns all folders in dir `name`.

func (*Client) ListN

func (c *Client) ListN(name string, n int) (list []os.FileInfo, err error)

ListN returns entries in dir `name`. Up to `n` entries, or all when `n` <= 0.

func (*Client) Mkdir

func (c *Client) Mkdir(name string) error

Mkdir creates folder `name`.

func (*Client) Move

func (c *Client) Move(src, dst string) error

Move file from `src` to `dst`.

func (*Client) Open

func (c *Client) Open(name string) *File

Open returns a File for reading and writing.

func (*Client) Preview

func (c *Client) Preview(name string) (io.ReadCloser, error)

Preview returns the PDF preview of `name`.

func (*Client) Read

func (c *Client) Read(name string) ([]byte, error)

Read returns the contents of `name`.

func (*Client) Search

func (c *Client) Search(path, query string) (list []os.FileInfo, err error)

Search return results for a search against `path` with the given `query`.

func (*Client) Stat

func (c *Client) Stat(name string) (os.FileInfo, error)

Stat returns file and directory meta-data for `name`.

func (*Client) Upload

func (c *Client) Upload(path string, r io.Reader) error

Upload reader to path (must be less than 150MB).

func (*Client) UploadSession

func (c *Client) UploadSession(path string, r io.Reader) error

Upload reader to path (must be larger than 150MB). Uses an internally managed upload session. The input reader will be split into 125MB chunks.

func (*Client) UploadSessionOptions

func (c *Client) UploadSessionOptions(opts UploadSessionOptions) (info os.FileInfo, err error)

Upload reader to path (must be larger than 150MB) and specify session options.

type File

type File struct {
	Name string
	// contains filtered or unexported fields
}

File implements an io.ReadWriteCloser for Dropbox files.

func (*File) Close

func (f *File) Close() error

Close implements io.Closer.

func (*File) Read

func (f *File) Read(b []byte) (int, error)

Read implements io.Reader

func (*File) Write

func (f *File) Write(b []byte) (int, error)

Write implements io.Writer.

type FileInfo

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

FileInfo wraps Dropbox file MetaData to implement os.FileInfo.

func (*FileInfo) IsDir

func (f *FileInfo) IsDir() bool

IsDir returns true if the file is a directory.

func (*FileInfo) ModTime

func (f *FileInfo) ModTime() time.Time

ModTime returns the modification time.

func (*FileInfo) Mode

func (f *FileInfo) Mode() os.FileMode

Mode returns the file mode flags.

func (*FileInfo) Name

func (f *FileInfo) Name() string

Name of the file.

func (*FileInfo) Size

func (f *FileInfo) Size() int64

Size of the file.

func (*FileInfo) Sys

func (f *FileInfo) Sys() interface{}

Sys is not implemented.

type UploadSessionOptions

type UploadSessionOptions struct {
	//When Size is known, UploadSession can prevent a superfluous request.
	//If not provided, Commit.Reader will be checked for a Size() int64 method.
	Size int64
	//ChunkSize is the number of bytes to upload in each call to append (defaults to 125MB).
	ChunkSize int64
	//Commit information for uploaded file
	Commit dropbox.UploadInput
}

UploadSessionInput request input.

Jump to

Keyboard shortcuts

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