Documentation ¶
Overview ¶
Package dropbox implements a simple v2 client.
Example ¶
Example using the Client, which provides both User and File clients.
d := dropbox.New(dropbox.NewConfig("<token>")) file, _ := os.Open("Readme.md") d.Files.Upload(&dropbox.UploadInput{ Path: "Readme.md", Reader: file, Mute: true, })
Output:
Example (Files) ¶
Example using the Files client directly.
files := dropbox.NewFiles(dropbox.NewConfig("<token>")) out, _ := files.Download(&dropbox.DownloadInput{ Path: "Readme.md", }) io.Copy(os.Stdout, out.Body)
Output:
Example (Users) ¶
Example using the Users client directly.
users := dropbox.NewUsers(dropbox.NewConfig("<token>")) out, _ := users.GetCurrentAccount() fmt.Printf("%v\n", out)
Output:
Index ¶
- Constants
- type Client
- type Config
- type CopyInput
- type CopyOutput
- type CreateFolderInput
- type CreateFolderOutput
- type CreateSharedLinkInput
- type CreateSharedLinkOutput
- type DeleteInput
- type DeleteOutput
- type DownloadInput
- type DownloadOutput
- type Error
- type Files
- func (c *Files) Copy(in *CopyInput) (out *CopyOutput, err error)
- func (c *Files) CreateFolder(in *CreateFolderInput) (out *CreateFolderOutput, err error)
- func (c *Files) Delete(in *DeleteInput) (out *DeleteOutput, err error)
- func (c *Files) Download(in *DownloadInput) (out *DownloadOutput, err error)
- func (c *Files) GetMetadata(in *GetMetadataInput) (out *GetMetadataOutput, err error)
- func (c *Files) GetPreview(in *GetPreviewInput) (out *GetPreviewOutput, err error)
- func (c *Files) GetThumbnail(in *GetThumbnailInput) (out *GetThumbnailOutput, err error)
- func (c *Files) ListFolder(in *ListFolderInput) (out *ListFolderOutput, err error)
- func (c *Files) ListFolderContinue(in *ListFolderContinueInput) (out *ListFolderOutput, err error)
- func (c *Files) ListRevisions(in *ListRevisionsInput) (out *ListRevisionsOutput, err error)
- func (c *Files) Move(in *MoveInput) (out *MoveOutput, err error)
- func (c *Files) PermanentlyDelete(in *PermanentlyDeleteInput) (err error)
- func (c *Files) Restore(in *RestoreInput) (out *RestoreOutput, err error)
- func (c *Files) Search(in *SearchInput) (out *SearchOutput, err error)
- func (c *Files) Upload(in *UploadInput) (out *UploadOutput, err error)
- type GetAccountInput
- type GetAccountOutput
- type GetCurrentAccountOutput
- type GetMetadataInput
- type GetMetadataOutput
- type GetPreviewInput
- type GetPreviewOutput
- type GetSpaceUsageOutput
- type GetThumbnailInput
- type GetThumbnailOutput
- type ListFolderContinueInput
- type ListFolderInput
- type ListFolderOutput
- type ListRevisionsInput
- type ListRevisionsOutput
- type Metadata
- type MoveInput
- type MoveOutput
- type PermanentlyDeleteInput
- type RestoreInput
- type RestoreOutput
- type SearchInput
- type SearchMatch
- type SearchMatchType
- type SearchMode
- type SearchOutput
- type Sharing
- type ThumbnailFormat
- type ThumbnailSize
- type UploadInput
- type UploadOutput
- type Users
- type VisibilityType
- type WriteMode
Examples ¶
Constants ¶
const ( SearchModeFilename SearchMode = "filename" SearchModeFilenameAndContent = "filename_and_content" SearchModeDeletedFilename = "deleted_filename" )
Supported search modes.
const ( SearchMatchFilename SearchMatchType = "filename" SearchMatchContent = "content" SearchMatchBoth = "both" )
Supported search match types.
const ( // GetThumbnailSizeW32H32 specifies a size of 32 by 32 px GetThumbnailSizeW32H32 ThumbnailSize = "w32h32" // GetThumbnailSizeW64H64 specifies a size of 64 by 64 px GetThumbnailSizeW64H64 = "w64h64" // GetThumbnailSizeW128H128 specifies a size of 128 by 128 px GetThumbnailSizeW128H128 = "w128h128" // GetThumbnailSizeW640H480 specifies a size of 640 by 480 px GetThumbnailSizeW640H480 = "w640h480" // GetThumbnailSizeW1024H768 specifies a size of 1024 by 768 px GetThumbnailSizeW1024H768 = "w1024h768" )
const ( Public VisibilityType = "public" TeamOnly = "team_only" Password = "password" TeamAndPassword = "team_and_password" )
Visibility types supported.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *Config Users *Users Files *Files Sharing *Sharing Token oauth2.Token TokenLock sync.Mutex }
Client implements a Dropbox client. You may use the Files and Users clients directly if preferred, however Client exposes them both.
type Config ¶
type Config struct { HTTPClient *http.Client AccessToken string RefreshToken string RefreshURL string }
Config for the Dropbox clients.
type CreateFolderInput ¶
type CreateFolderInput struct {
Path string `json:"path"`
}
CreateFolderInput request input.
type CreateFolderOutput ¶
type CreateFolderOutput struct { Name string `json:"name"` PathLower string `json:"path_lower"` ID string `json:"id"` }
CreateFolderOutput request output.
type CreateSharedLinkInput ¶
type CreateSharedLinkInput struct {}
CreateSharedLinkInput request input.
type CreateSharedLinkOutput ¶
type CreateSharedLinkOutput struct { VisibilityType `json:".tag"` } `json:"visibility"` }Tag
CreateSharedLinkOutput request output.
type DownloadInput ¶
type DownloadInput struct {
Path string `json:"path"`
}
DownloadInput request input.
type DownloadOutput ¶
type DownloadOutput struct { Body io.ReadCloser Length int64 }
DownloadOutput request output.
type Files ¶
type Files struct {
*Client
}
Files client for files and folders.
func (*Files) Copy ¶
func (c *Files) Copy(in *CopyInput) (out *CopyOutput, err error)
Copy a file or folder to a different location.
func (*Files) CreateFolder ¶
func (c *Files) CreateFolder(in *CreateFolderInput) (out *CreateFolderOutput, err error)
CreateFolder creates a folder.
func (*Files) Delete ¶
func (c *Files) Delete(in *DeleteInput) (out *DeleteOutput, err error)
Delete a file or folder and its contents.
func (*Files) Download ¶
func (c *Files) Download(in *DownloadInput) (out *DownloadOutput, err error)
Download a file.
func (*Files) GetMetadata ¶
func (c *Files) GetMetadata(in *GetMetadataInput) (out *GetMetadataOutput, err error)
GetMetadata returns the metadata for a file or folder.
func (*Files) GetPreview ¶
func (c *Files) GetPreview(in *GetPreviewInput) (out *GetPreviewOutput, err error)
GetPreview a preview for a file. Currently previews are only generated for the files with the following extensions: .doc, .docx, .docm, .ppt, .pps, .ppsx, .ppsm, .pptx, .pptm, .xls, .xlsx, .xlsm, .rtf
func (*Files) GetThumbnail ¶
func (c *Files) GetThumbnail(in *GetThumbnailInput) (out *GetThumbnailOutput, err error)
GetThumbnail a thumbnail for a file. Currently thumbnails are only generated for the files with the following extensions: png, jpeg, png, tiff, tif, gif and bmp.
func (*Files) ListFolder ¶
func (c *Files) ListFolder(in *ListFolderInput) (out *ListFolderOutput, err error)
ListFolder returns the metadata for a file or folder.
func (*Files) ListFolderContinue ¶
func (c *Files) ListFolderContinue(in *ListFolderContinueInput) (out *ListFolderOutput, err error)
ListFolderContinue pagenates using the cursor from ListFolder.
func (*Files) ListRevisions ¶
func (c *Files) ListRevisions(in *ListRevisionsInput) (out *ListRevisionsOutput, err error)
ListRevisions gets the revisions of the specified file.
func (*Files) Move ¶
func (c *Files) Move(in *MoveInput) (out *MoveOutput, err error)
Move a file or folder to a different location.
func (*Files) PermanentlyDelete ¶
func (c *Files) PermanentlyDelete(in *PermanentlyDeleteInput) (err error)
PermanentlyDelete a file or folder and its contents.
func (*Files) Restore ¶
func (c *Files) Restore(in *RestoreInput) (out *RestoreOutput, err error)
Restore a file to a specific revision.
func (*Files) Search ¶
func (c *Files) Search(in *SearchInput) (out *SearchOutput, err error)
Search for files and folders.
func (*Files) Upload ¶
func (c *Files) Upload(in *UploadInput) (out *UploadOutput, err error)
Upload a file smaller than 150MB.
type GetAccountInput ¶
type GetAccountInput struct {
AccountID string `json:"account_id"`
}
GetAccountInput request input.
type GetAccountOutput ¶
type GetAccountOutput struct { AccountID string `json:"account_id"` Name struct { GivenName string `json:"given_name"` Surname string `json:"surname"` FamiliarName string `json:"familiar_name"` DisplayName string `json:"display_name"` } `json:"name"` }
GetAccountOutput request output.
type GetCurrentAccountOutput ¶
type GetCurrentAccountOutput struct { AccountID string `json:"account_id"` Name struct { GivenName string `json:"given_name"` Surname string `json:"surname"` FamiliarName string `json:"familiar_name"` DisplayName string `json:"display_name"` } `json:"name"` Email string `json:"email"` Locale string `json:"locale"` ReferralLink string `json:"referral_link"` IsPaired bool `json:"is_paired"` AccountType struct { Tag string `json:".tag"` } `json:"account_type"` Country string `json:"country"` }
GetCurrentAccountOutput request output.
type GetMetadataInput ¶
type GetMetadataInput struct { Path string `json:"path"` IncludeMediaInfo bool `json:"include_media_info"` }
GetMetadataInput request input.
type GetMetadataOutput ¶
type GetMetadataOutput struct {
Metadata
}
GetMetadataOutput request output.
type GetPreviewInput ¶
type GetPreviewInput struct {
Path string `json:"path"`
}
GetPreviewInput request input.
type GetPreviewOutput ¶
type GetPreviewOutput struct { Body io.ReadCloser Length int64 }
GetPreviewOutput request output.
type GetSpaceUsageOutput ¶
type GetSpaceUsageOutput struct { Used uint64 `json:"used"` Allocation struct { Used uint64 `json:"used"` Allocated uint64 `json:"allocated"` } `json:"allocation"` }
GetSpaceUsageOutput request output.
type GetThumbnailInput ¶
type GetThumbnailInput struct { Path string `json:"path"` Format ThumbnailFormat `json:"format"` Size ThumbnailSize `json:"size"` }
GetThumbnailInput request input.
type GetThumbnailOutput ¶
type GetThumbnailOutput struct { Body io.ReadCloser Length int64 }
GetThumbnailOutput request output.
type ListFolderContinueInput ¶
type ListFolderContinueInput struct {
Cursor string `json:"cursor"`
}
ListFolderContinueInput request input.
type ListFolderInput ¶
type ListFolderInput struct { Path string `json:"path"` Recursive bool `json:"recursive"` IncludeMediaInfo bool `json:"include_media_info"` IncludeDeleted bool `json:"include_deleted"` }
ListFolderInput request input.
type ListFolderOutput ¶
type ListFolderOutput struct { Cursor string `json:"cursor"` HasMore bool `json:"has_more"` Entries []*Metadata }
ListFolderOutput request output.
type ListRevisionsInput ¶
ListRevisionsInput request input.
type ListRevisionsOutput ¶
ListRevisionsOutput request output.
type Metadata ¶
type Metadata struct { Tag string `json:".tag"` Name string `json:"name"` PathLower string `json:"path_lower"` ClientModified time.Time `json:"client_modified"` ServerModified time.Time `json:"server_modified"` Rev string `json:"rev"` Size uint64 `json:"size"` ID string `json:"id"` }
Metadata for a file or folder.
type PermanentlyDeleteInput ¶
type PermanentlyDeleteInput struct {
Path string `json:"path"`
}
PermanentlyDeleteInput request input.
type RestoreInput ¶
RestoreInput request input.
type SearchInput ¶
type SearchInput struct { Path string `json:"path"` Query string `json:"query"` Start uint64 `json:"start,omitempty"` MaxResults uint64 `json:"max_results,omitempty"` Mode SearchMode `json:"mode"` }
SearchInput request input.
type SearchMatch ¶
type SearchMatch struct { MatchType struct { Tag SearchMatchType `json:".tag"` } `json:"match_type"` Metadata *Metadata `json:"metadata"` }
SearchMatch represents a matched file or folder.
type SearchMatchType ¶
type SearchMatchType string
SearchMatchType represents the type of match made.
type SearchOutput ¶
type SearchOutput struct { Matches []*SearchMatch `json:"matches"` More bool `json:"more"` Start uint64 `json:"start"` }
SearchOutput request output.
type Sharing ¶
type Sharing struct {
*Client
}
Sharing client.
func (*Sharing) CreateSharedLink ¶
func (c *Sharing) CreateSharedLink(in *CreateSharedLinkInput) (out *CreateSharedLinkOutput, err error)
CreateSharedLink returns a shared link.
type ThumbnailFormat ¶
type ThumbnailFormat string
ThumbnailFormat determines the format of the thumbnail.
const ( // GetThumbnailFormatJPEG specifies a JPG thumbnail GetThumbnailFormatJPEG ThumbnailFormat = "jpeg" // GetThumbnailFormatPNG specifies a PNG thumbnail GetThumbnailFormatPNG = "png" )
type ThumbnailSize ¶
type ThumbnailSize string
ThumbnailFormat determines the size of the thumbnail.
type UploadInput ¶
type UploadInput struct { Path string `json:"path"` Mode WriteMode `json:"mode"` AutoRename bool `json:"autorename"` Mute bool `json:"mute"` ClientModified time.Time `json:"client_modified,omitempty"` Reader io.ReadSeeker `json:"-"` }
UploadInput request input.
type Users ¶
type Users struct {
*Client
}
Users client for user accounts.
func (*Users) GetAccount ¶
func (c *Users) GetAccount(in *GetAccountInput) (out *GetAccountOutput, err error)
GetAccount returns information about a user's account.
func (*Users) GetCurrentAccount ¶
func (c *Users) GetCurrentAccount() (out *GetCurrentAccountOutput, err error)
GetCurrentAccount returns information about the current user's account.
func (*Users) GetSpaceUsage ¶
func (c *Users) GetSpaceUsage() (out *GetSpaceUsageOutput, err error)
GetSpaceUsage returns space usage information for the current user's account.