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 ¶
- type Client
- func (c *Client) Copy(src, dst string) error
- func (c *Client) Delete(name string) error
- func (c *Client) Download(name string) (io.ReadCloser, error)
- func (c *Client) List(name string) ([]os.FileInfo, error)
- func (c *Client) ListFiles(name string) ([]os.FileInfo, error)
- func (c *Client) ListFilter(name string, filter func(info os.FileInfo) bool) (ret []os.FileInfo, err error)
- func (c *Client) ListFolders(name string) ([]os.FileInfo, error)
- func (c *Client) ListN(name string, n int) (list []os.FileInfo, err error)
- func (c *Client) Mkdir(name string) error
- func (c *Client) Move(src, dst string) error
- func (c *Client) Open(name string) *File
- func (c *Client) Preview(name string) (io.ReadCloser, error)
- func (c *Client) Read(name string) ([]byte, error)
- func (c *Client) Search(path, query string) (list []os.FileInfo, err error)
- func (c *Client) Stat(name string) (os.FileInfo, error)
- func (c *Client) Upload(path string, r io.Reader) error
- func (c *Client) UploadSession(path string, r io.Reader) error
- func (c *Client) UploadSessionOptions(opts UploadSessionOptions) (info os.FileInfo, err error)
- type File
- type FileInfo
- type UploadSessionOptions
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 (*Client) Download ¶
func (c *Client) Download(name string) (io.ReadCloser, error)
Download returns the contents of `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 ¶
ListFolders returns all folders in dir `name`.
func (*Client) ListN ¶
ListN returns entries in dir `name`. Up to `n` entries, or all when `n` <= 0.
func (*Client) Preview ¶
func (c *Client) Preview(name string) (io.ReadCloser, error)
Preview returns the PDF preview of `name`.
func (*Client) UploadSession ¶
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.
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo wraps Dropbox file MetaData to implement os.FileInfo.
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.