Documentation
¶
Index ¶
- Variables
- type Box
- type BoxError
- type BoxLock
- type BoxTime
- type Collection
- type Entity
- type File
- func (f *File) Copy(box *Box, parent *Folder) (*File, error)
- func (f *File) Delete(box *Box) error
- func (f *File) Download(box *Box, writer io.Writer) error
- func (f *File) DownloadFile(box *Box, path string) error
- func (f *File) Get(box *Box) error
- func (f *File) Move(box *Box, parent *Folder) error
- func (f *File) Rename(box *Box, name string) error
- func (f *File) Upload(box *Box, reader io.Reader, parent *Folder) error
- func (f *File) UploadFile(box *Box, path string, parent *Folder) error
- type Folder
- func (f *Folder) Copy(box *Box, parent *Folder) (*Folder, error)
- func (f *Folder) Create(box *Box, name string) (*Folder, error)
- func (f *Folder) Delete(box *Box) error
- func (f *Folder) Get(box *Box) error
- func (f *Folder) Items(box *Box) ([]Entity, error)
- func (f *Folder) Move(box *Box, parent *Folder) error
- func (f *Folder) Rename(box *Box, name string) error
- func (f *Folder) Share(box *Box, download, preview bool) error
- func (f *Folder) Unshare(box *Box) error
- type Permission
- type SharedObject
- type UploadEmail
Constants ¶
This section is empty.
Variables ¶
var ( SUCCESS = &BoxError{200, "Success"} CREATED = &BoxError{201, "Created"} ACCEPTED = &BoxError{202, "Accepted"} NO_CONTENT = &BoxError{204, "No Content"} )
var ( REDIRECT = &BoxError{302, "Redirect"} NOT_MODIFIED = &BoxError{304, "Not Modified"} )
var ( UNAUTHORIZED = &BoxError{401, "Unauthorized"} // Authorization failed FORBIDDEN = &BoxError{403, "Forbidden"} // Not enough permission for the operation NOT_FOUND = &BoxError{404, "Not found"} // Not Found NOT_ALLOWED = &BoxError{405, "Not allowed"} // Method not allowed CONFLICT = &BoxError{409, "Conflict"} // Same name item already exist PRECONDITION_FAILED = &BoxError{412, "Precondition failed"} // Precondition (If match) failed TOO_MANY_REQUESTS = &BoxError{429, "Too many requests"} // Too many requests )
var ( SERVER_ERROR = &BoxError{500, "Internal server error"} // Internal server error UNAVAILABLE = &BoxError{503, "Unavailable"} // Unavailable )
Functions ¶
This section is empty.
Types ¶
type Box ¶
Box Client
func (*Box) AccessToken ¶
AccessToken returns the OAuth access token.
func (*Box) SetAccessToken ¶
SetAccessToken sets access token to avoid calling Auth method.
func (*Box) SetAppInfo ¶
SetAppInfo adds oauth2 app info
type BoxTime ¶
func (BoxTime) MarshalJSON ¶
MarshalJSON marshals a time according to the Dropbox format.
func (*BoxTime) UnmarshalJSON ¶
UnmarshalJSON unmarshals a time according to the Dropbox format.
type Collection ¶
type Entity ¶
type Entity struct {
SequenceId string `json:"sequence_id,omitempty"` // A unique ID for use with the /events endpoint.
Name string `json:"name,omitempty"` // The name of the entity.
Id string `json:"id,omitempty"` // The id of the entity.
ETag string `json:"etag,omitempty"` // A unique string identifying the version of this entity.
Type string `json:"type,omitempty"` // Type of entity
}
Represents both mini folder and mini file.
type File ¶
type File struct {
Id string `json:"id,omitempty"` // Box’s unique string identifying this file.
SequenceId string `json:"sequence_id,omitempty"` // A unique ID for use with the /events endpoint.
ETag string `json:"etag,omitempty"` // A unique string identifying the version of this file.
Sha1 string `json:"sha1,omitempty"` // The sha1 hash of this file.
Name string `json:"name,omitempty"` // The name of this file.
Description string `json:"description,omitempty"` // The description of this file.
Size int `json:"size,omitempty"` // Size of this file in bytes.
PathCollection *Collection `json:"path_collection,omitempty"` // The path of folders to this item, starting at the root.
CreatedAt *BoxTime `json:"created_at,omitempty"` // When this file was created on Box’s servers.
ModifiedAt *BoxTime `json:"modified_at,omitempty"` // When this file was last updated on the Box servers.
ThrashedAt *BoxTime `json:"thrashed_at,omitempty"` // When this file was last moved to the trash.
PurgedAt *BoxTime `json:"purged_at,omitempty"` // When this file will be permanently deleted.
ContentCreatedAt *BoxTime `json:"content_created_at,omitempty"` // When the content of this file was created.
ContentModifiedAt *BoxTime `json:"content_modified_at,omitempty"` // When the content of this file was last modified.
CreatedBy *Entity `json:"created_by,omitempty"` // The user who first created file.
ModifiedBy *Entity `json:"modified_by,omitempty"` // The user who last updated this file.
OwnedBy *Entity `json:"owned_by,omitempty"` // The user who owns this file.
Parent *Entity `json:"parent,omitempty"` // The folder containing this file.
ItemStatus string `json:"item_status,omitempty"` // Whether this item is deleted or not.
VersionNumber string `json:"version_number,omitempty"` // The version of the file.
CommentCount int `json:"comment_count,omitempty"` // The number of comments on a file.
Permissions *Permission `json:"permissions,omitempty"` // The permissions that the current user has on this file.
Tags []string `json:"tags,omitempty"` // All tags applied to this file.
Lock *BoxLock `json:"lock,omitempty"` // The lock held on the file.
Extension string `json:"extension,omitempty"` // Indicates the suffix, when available, on the file.
}
func (*File) Copy ¶
Copy copies the current file under the given parent. Note that only Id is required apriori for both file and parent folder. The copied file is returned after copy is successful.
func (*File) DownloadFile ¶
Download downloads the file at the given file path. File will be overwritten if it already exists. Note that only file id is required apriori.
func (*File) Get ¶
Get populates the fields of the file struct. Node that only Id is required apriori.
func (*File) Move ¶
Move moves the current file under the given parent. Note that only Id is required apriori for both file and parent folder. The file is populated with all the information after the call.
func (*File) Rename ¶
Rename renames the file with the new name. Note that only Id is required apriori. The file object is populated with all the information after the call.
func (*File) Upload ¶
Upload uploads the file (given by the reader) at the given file path. The file name on the box server is taken from the Name attribute of file object. After upload, it then fills the information of the recently uploaded file in the file object. Note that Id attribute is required for the parent folder.
func (*File) UploadFile ¶
UploadFile directly uploads the file on the box server. The name is taken from the Name attribute of the file object (if it is empty, file name is chosen). Note than only parent id is required apriori for the parent folder.
type Folder ¶
type Folder struct {
Id string `json:"id,omitempty"` // The folder’s ID.
SequenceId string `json:"sequence_id,omitempty"` // A unique ID for use with the /events endpoint.
ETag string `json:"etag,omitempty"` // A unique string identifying the version of this folder.
Name string `json:"name,omitempty"` // The name of this folder.
Description string `json:"description,omitempty"` // The description of this folder.
Size int `json:"size,omitempty"` // Size of this file in bytes.
PathCollection *Collection `json:"path_collection,omitempty"` // The path of folders to this item, starting at the root.
CreatedAt *BoxTime `json:"created_at,omitempty"` // The time the folder was created.
ModifiedAt *BoxTime `json:"modified_at,omitempty"` // The time the folder or its contents were last modified.
ThrashedAt *BoxTime `json:"thrashed_at,omitempty"` // The time the folder or its contents were put in the trash.
PurgedAt *BoxTime `json:"purged_at,omitempty"` // The time the folder or its contents were purged from the trash.
ContentCreatedAt *BoxTime `json:"content_created_at,omitempty"` // The time the folder or its contents were originally created (according to the uploader).
ContentModifiedAt *BoxTime `json:"content_modified_at,omitempty"` // The time the folder or its contents were last modified (according to the uploader).
CreatedBy *Entity `json:"created_by,omitempty"` // The user who created this folder.
ModifiedBy *Entity `json:"modified_by,omitempty"` // The user who last modified this folder.
OwnedBy *Entity `json:"owned_by,omitempty"` // The user who owns this file.
Parent *Entity `json:"parent,omitempty"` // The folder that contains this one.
ItemStatus string `json:"item_status,omitempty"` // Whether this item is deleted or not.
Permissions *Permission `json:"permissions,omitempty"` // The permissions that the current user has on this file.
Tags []string `json:"tags,omitempty"` // All tags applied to this file.
HasCollaborations bool `json:"has_collaborations,omitempty"` // Whether this folder has any collaborators.
SyncStatus string `json:"sync_status,omitempty"` // Whether this folder will be synced by the Box sync clients or not. Can be
ItemCollection *Collection `json:"item_collection,omitempty"` // A collection of mini file and folder objects contained in this folder.
FolderUploadEmail *UploadEmail `json:"folder_upload_email,omitempty"` // The upload email address for this folder. Null if not set.
}
func (*Folder) Copy ¶
Copy copies the current folder under the given parent. Note that only Id is required apriori for both parent and current folder. The copied folder is returned after copy is successful.
func (*Folder) Create ¶
Create creates a sub folder under the given folder. It returns the created folder. Note that only Id of the parent folder is required apriori.
func (*Folder) Items ¶
Items returns all items (folder or files) under the given folder. It calls Get if the folder is not already populated.
func (*Folder) Move ¶
Move moves the current folder under the given parent. Note that only Id is required apriori for both parent and current folder. The folder is populated with all the information after the call.
func (*Folder) Rename ¶
Rename renames the folder with the new name. Note that only Id is required apriori. The folder is populated with all the information after the call.
func (*Folder) Share ¶
Share creates a share link. download and preview sets appropriate permissions on the shared link. It only supports open sharing. Note that only folder Id is required apriori. The folder is populated with all the information after the call. You can get the SharedObject by accessing appropriate field of the folder.
type Permission ¶
type SharedObject ¶
type SharedObject struct {
}