Box¶
Class that allows for access to the box API and methods to directly upload files
-
class
dapt.box.
Box
(*args, **kwargs)¶ Class which allows for connection to box API. You must either provide a Config object or client_id and client_secret.
Keyword Arguments: - config (Config) – A Config object which contains the client_id and client_secret.
- client_id (str) – The Box client ID.
- client_secret (str) – The Box client secret.
-
connect
(access_token=None, refresh_token=None)¶ Tries to connect to box using arguments provided in Config and starts server for authorization if not.
Parameters: - access_token (str) – Optional argument that allows DAPT to connect to box without going through web authentification (assuming refresh_token is given and not expired).
- refresh_token (str) – Optional argument that allows DAPT to connect to box without going through web authentification (assuming access_token is given and not expired).
Returns: Box client if successful
-
updateTokens
(access_token)¶ Refresh the access and refresh token given a valid access token
Parameters: access_token (string) – box access token to be refreshed Returns: Box client
-
uploadFile
(folderID, path, name)¶ Upload a file to box using the current client
Parameters: - folderID (string) – the box folder ID that the file should be added to (found in URL)
- path (string) – the path to the file on your local machine
- file (string) – the name of the file you wish to upload