| Type: | Package |
| Title: | Interface for the 'Box.com API' |
| Version: | 0.3.7 |
| URL: | https://r-box.github.io/boxr/,https://github.com/r-box/boxr |
| BugReports: | https://github.com/r-box/boxr/issues |
| Description: | An R interface for the remote file hosting service 'Box' (https://www.box.com/). In addition to uploading and downloading files, this package includes functions which mirror base R operations for local files, (e.g. box_load(), box_save(), box_read(), box_setwd(), etc.), as well as 'git' style functions for entire directories (e.g. box_fetch(), box_push()). |
| License: | MIT + file LICENSE |
| Imports: | assertthat, dplyr, digest, fs, glue, httr (≥ 1.1.0),magrittr, mime, purrr, rio (≥ 0.5.18), rlang, stats, stringr,utils, tibble, lifecycle, jsonlite, jose, cli, withr |
| Suggests: | clipr (≥ 0.3.0), conflicted, gargle (≥ 0.3.0), here, knitr,openssl, png, rmarkdown, sodium, testthat, usethis, covr |
| VignetteBuilder: | knitr |
| RoxygenNote: | 7.3.2 |
| Encoding: | UTF-8 |
| RdMacros: | lifecycle |
| NeedsCompilation: | no |
| Packaged: | 2025-04-13 15:22:43 UTC; ijlyttle |
| Author: | Brendan Rocks [aut], Ian Lyttle |
| Maintainer: | Ian Lyttle <ijlyttle@me.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-04-13 15:50:02 UTC |
boxr: access the Box API
Description
A lightweight,opinionated, high-level R interface for thebox.com API.
Details
This package has a documentation-website (created usingpkgdown), containing:
Get-started article,also accessible from R:
vignette("boxr").
The boxr source-repository is at GitHub:https://github.com/r-box/boxr.
If you find anything you think might be a bug, please report it as aGitHub issue!
Happy hacking! :)
Author(s)
Maintainer: Ian Lyttleijlyttle@me.com (ORCID)
Authors:
Brendan Rocksfoss@brendanrocks.com
Nathan Daynathancday@gmail.com (ORCID)
Other contributors:
Vincent Fulco [contributor]
Alec Wong [contributor]
Alex Brodersen [contributor]
See Also
Useful links:
Report bugs athttps://github.com/r-box/boxr/issues
Pipe operator
Description
Seemagrittr::%>% for details.
Usage
lhs %>% rhsIssue a get request for a file stored on box.com
Description
This internal function is shared bybox_dl(), and thebox_read() family of functions, to issue GET requests, whilehandling things like version numbers etc. It can be used to download a file,or just read it into memory.
Usage
boxGet( file_id, local_file, version_id = NULL, version_no = NULL, download = FALSE, pb = FALSE)Add description to a Box file
Description
These functions will attach a description or comment to a Box file. A newdescription will overwrite an existing one.
Usage
box_add_description(file_id, description)Arguments
file_id |
|
description |
|
Details
Files hosted at Box can have small text-descriptions thatyou can be use to annotate files, or even to
Value
Object with S3 classboxr_file_reference.
Authenticate to Box (interactive-app)
Description
There are two common use-cases forbox_auth():
Connecting tobox.comaccounts fromboxr for the first time.
Connecting to previously-connectedbox.com accounts.
In the first case, you will need to providebox_auth() withclient_id andclient_secret.
In the second case, you can callbox_auth() with no arguments;the function will look for these in your R environment.
To run this function the first time, you will need access to theclient_idandclient_secret of a Box interactive-app. If you are using a work account,this information might be provided to you by your Box-admin team. If you areusing a personal account, you will have to set up a Box interactive-app.
For both cases, these procedures are detailed in this boxrinteractive-app article.
Usage
box_auth( client_id = NULL, client_secret = NULL, interactive = TRUE, cache = "~/.boxr-oauth", write.Renv, ...)Arguments
client_id |
|
client_secret |
|
interactive |
|
cache | A logical value or a string. |
write.Renv | deprecated. |
... | Other arguments passed to |
Value
InvisibleNULL, called for side effects.
Side-effects
This function has some side effects which make subsequent calls tobox_auth() easier:
a browser window may be opened atbox.com,for you to authorize to your Box app.
a token file is written, according to the value of
cache. The defaultbehavior is to write this file to~/.boxr-oauth.For all platforms,~resolves to the home directory, i.e. path isresolved usingfs::path_expand()rather thanfs::path_expand_r().some global
options()are set for your session to manage the token.environment variables
BOX_USER_ID,BOX_CLIENT_ID,andBOX_CLIENT_SECRETare set.if these environment variables have changed, and you have theusethis package installed, it will copysome text to your clipboard that you can paste into your
.Renvironfile.a message is printed to the console.
See Also
box_auth_service()for authenticating to service-apps.
httr::oauth2.0_token()for details on how tokens are handled.
- Box Developers: Setup with OAuth 2.0
documentation for setting up Box (interactive) apps with OAuth 2.0.
Authenticate to Box (interactive) automatically
Description
This function is deprecated, and may be removed at the next release.
This function saves you the effort of typingbox_auth() afterthe package loads. Executingbox_auth_on_attach(TRUE) will mean thatboxr will automatically attempt to authorize itself when'attached' (e.g.library(boxr)), using the credentials from thecurrent session.
Usage
box_auth_on_attach(auth_on_attach = FALSE)Arguments
auth_on_attach |
|
Value
InvisibleNULL, called for side effects.
Note
This is provided for convenience, but it's a bad idea to use, if:
You'd like your code to be reproducible. Even if yourcollaborators have access to the same files on box.com, as the defaultbehaviour is to require using
box_auth(), code is likely tobecome irreproducible.You use more than one box.com account. Things could getrather confusing.
See Also
Authenticate to Box (service-app)
Description
How you authenticate to Box depends the Box-app through which youconnect. A Box service-app can be useful for unattended jobs that needaccess to only a limited part of Box, e.g. one folder.
Use this function to access Box using a service-app.
To access a service-app, you will need a JSON web-token (JWT),generated by your Box-admin team. If you have a personal Box account,youare your Box-admin team. You specify the JWT either astoken_file,the path to the JWT file, or astoken_text, the text of the JWT.
Using JWT-authentication is more convenient than using standard OAuth2authentication, as you do not have to go through the "OAuth Dance". Thisconvenience brings additional considerations because the JWT file givesits bearer uninhibited access to anything the Box service-app can access.Accordingly, you are recommended to:
give the service-account access to as little information as you need itto have, e.g. a single folder.
keep the JWT file secure.
Usage
box_auth_service(token_file = NULL, token_text = NULL)Arguments
token_file |
|
token_text |
|
Details
The default behavior of a service-app is to act on behalf of theservice-account associated with the service-app. This is differentfrom an interactive-app, which acts on behalf of the Box user whoauthenticates to it.
To use a service-app on a folder belonging to a Box user, eitherthe Box user has to invite the service-account to collaborate on afolder belonging to the user, or the service-account has to invite theBox user to collaborate on a folder belonging to the service-account.
In either case, you can usebox_collab_create().
In mid-2020, there appeared intermittent and unexplained failures ofbox_auth_service(); the theory is that the clocks at either endof the authentication process can be out-of-sync. The workaroundis to watch for this failure, then retry the authentication requestwith a time-offset. If an offset is used, this function generates a message.
For more details on Box service-apps, including how to create them, andservice-app-based workflows, please read this boxrservice-app article.
Value
InvisibleNULL, called for side effects.
Side-effects
This function has some side effects:
some global
options()are set for your session to manage the token.a message is printed to the console.
See Also
box_auth()for authenticating to interactive-apps.
box_collab_create()for creating a collaboration with a different accounton a Box file or folder.
- Box Developers: Setup with JWT](https://developer.box.com/en/guides/applications/custom-apps/jwt-setup)
documentation for setting up Box (service) apps with JWT.
Open a Box directory or file in browser
Description
Thin wrapper ofutils::browseURL() to make bouncing between R and Box a breeze.
Usage
box_browse(dir_id = NULL, file_id = NULL)Arguments
dir_id |
|
file_id |
|
Value
InvisibleNULL, called for side effects.
Examples
## Not run: box_browse(0) # root folder on Box box_browse(file_id = 12345)## End(Not run)Create Box collaboration
Description
Although this function can be used in all sorts of situations, it can beparticularly useful in setting up a workflow with a service-account:
If you are authenticated as a user, using
box_auth(), you can invitethe service account to collaborate on a folder in youruser filespace.In this case, the shared folder will appear in the service-accountfilespace.If you are authenticated as the service-account using
box_auth_service(), you can invite youruser-account to collaborate.In this case, the shared folder will appear in your user file-space.
Once you issue an invitation to create a collaboration, you cannot change it,e.g. you cannot change therole from"viewer" to"co-owner".However, you can delete the collaboration, then issue anew invitation.To delete a collaboration, usebox_collab_delete(). To check a Box folder ID or file IDfor existing collaborations, usebox_collab_get().You can also use the Box web-portal to manage collaborations.
The defaultrole, i.e. permission level, for an invitationis"editor". Legal values forrole are"editor","viewer","previewer","uploader","previewer uploader","viewer uploader","co-owner","owner".
Usage
box_collab_create( dir_id = NULL, user_id = NULL, file_id = NULL, group_id = NULL, login = NULL, role = "editor", can_view_path = FALSE)Arguments
dir_id |
|
user_id |
|
file_id |
|
group_id |
|
login |
|
role |
|
can_view_path |
|
Details
To use this function, you must provide exactly one of:dir_id orfile_id,to specify what you want to share, and exactly one of:user_id,group_id, orlogin (email address), to specify the account you want toshare it with.
While authenticated from the host account, the one that will issue theinvitation, you can usebox_ls() andbox_setwd() to get thedir_idorfile_id for the item you want to share. If the host-account is theuser-account, you can also use the web-portal to find thedir_id orfile-id. If the host account is the service-account, you can use the Boxcontent-portal to find this.
A user can find theiruser_id using the Box web-portal. As well, whenyou authenticate using boxr, theuser_id is included in the loginmessage. Thus, you can usebox_auth_service() to find out theuser_idfor a given service-account.
This returns an object with S3 classboxr_collab;this is a list containing the response from the API. You can useas_tibble() oras.data.frame() on this return-object to convert toa tibble or data frame.
Value
Object with S3 classboxr_collab.
See Also
Delete Box collaboration
Description
Delete Box collaboration
Usage
box_collab_delete(collab_id)Arguments
collab_id |
|
Value
InvisibleNULL, called for side effects.
Get Box collaborations
Description
Retrieve information on all collaborations on a file or folder.
Usage
box_collab_get(dir_id = NULL, file_id = NULL)Arguments
dir_id |
|
file_id |
|
Details
You must specify exactly one ofdir_id orfile_id.
This returns an object with S3 classboxr_collab_list;this is a list containing the response from the API. You can useas_tibble() oras.data.frame() on this return-object to convert toa tibble or data frame.
Value
Object with S3 classboxr_collab_list.
Create/get Box comments
Description
Use these functions to create and get comments for Box files.
Usage
box_comment_create(file_id = NULL, message, comment_id = NULL)box_comment_get(file_id)Arguments
file_id |
|
message |
|
comment_id |
|
Details
When you create a comment usingbox_comment_create(), you have to specifyafile_id or acomment_id. If you specify acomment_id, the commentwill be posted as a reply to that comment.
Usebox_comment_get() to retrieve comments in bulk. This gets all thecomments associated with a file, thus you can specify only afile_id.
Value
box_comment_create()Object with S3 class
boxr_comment.box_comment_get()Object with S3 class
boxr_comment_list.
Examples
## Not run: file_id <- 12345 # create comments x <- box_comment_create(file_id, "Report is ready.") box_comment_create(comment_id = x$id, message = "Response to a comment") # get comments box_comment_get(file_id)## End(Not run)Move files within Box, from/to trash directory
Description
In the Box context, deleting a file moves it to a special folderwithin your Box account: 'Trash'. As of mid-2019, Box' defaultpolicyis to retain files in Trash for 30 days.
Usage
box_delete_file(file_id)box_restore_file(file_id)box_delete_folder(dir_id)box_restore_folder(dir_id)Arguments
file_id |
|
dir_id |
|
Details
box_delete_file()Move a file to Trash.
box_restore_file()Restore a file from Trash.
box_delete_folder()Move a folder, including contents, to Trash.
box_restore_folder()Restore a folder, including contents, from Trash.
Value
box_delete_file()Invisible
NULL, called for side effects.box_restore_file()Object with S3 class
boxr_file_reference.box_delete_folder()Invisible
NULL, called for side effects.box_restore_folder()Object with S3 class
boxr_folder_reference.
Create a Box directory
Description
This will create a new folder at Box, with namedir_name,in the Box folder with IDparent_dir_id.
Usage
box_dir_create(dir_name, parent_dir_id = box_getwd())Arguments
dir_name |
|
parent_dir_id |
|
Value
Object with S3 classboxr_folder_reference.
See Also
box_delete_folder() to move Box folders to trash,box_ls() to list files in a Box folder.
Compare the contents of Remote and Local Directories
Description
box_dir_diff is the internal function used bybox_fetch() andbox_push() to determine how towhich files and folders should be uploaded/downloaded, updated,or deleted, to synchronize remote and local directories.
Usage
box_dir_diff( dir_id = box_getwd(), local_dir = getwd(), load = "up", folders = FALSE)Arguments
dir_id | The id of the box.com folder which you'd like to use for thecomparison |
local_dir | The path of the local folder which you'd like to use for thecomparison |
load |
|
folders |
|
Details
box_dir_diff works by comparing files in the'origin' tothose in the'destination'.
For downloading files (e.g. withbox_fetch()), the origin isthe remote folder on box.com specified withdir_id, and thedestination would be the local directory specified bylocal_dir.
The reverse is true for uploads (e.g. viabox_fetch()).
box_dir_diff decides what should happen to a file based on three
- Presence
Is the file present in both the origin and destination? The filename(within the directory structure) is used to determine this.
- Content
If a file is present in both the origin and the destination, does ithave the same content? The definition comes from the file's
sha1hash, which for local files is determined using thedigest::digest()function from the package of the same name. Forremote files, it is queried from the box.com API.- Modification Date
If a file is present in both the origin and destination, and thecontent is different in each, boxr will prefer the file which was mostrecently modified.
For local files, the 'content modified time' is used; the
mtimevariable returned byfile.info().For remote files, the
modified_atdate returned by the box.com API.This is the time that the file was modified on the box.com servers, asopposed to the time that the content itself was modified.
Why not use the content modified time for both?
With regards to the box.com API,modified_at is preferred tocontent_modified_at, as it includes changes to the file outside ofjust it's content. This means that, for example, a collaborator couldroll back to a previous version of a file, or upload a preferred butolder version. These actions count as modifications on the box.comservers, but not to the content of the file itself (they are reflectedinmodified_at, but notcontent_modified_at).
Implementing similar functionality for local files is not possible in aplatform-independent manner; content modified time is the only file-basedtimestamp which has a consistent definition for UNIX and Windowssystems.
Value
An object of classboxr_dir_comparison, describing thedifferences between the files.
It is a named list, it's entries containing data frames,describing the files in each of the following categories:
newFiles which are present in the origin, but not the destination. Thesewill be downloaded by
box_fetch()/uploaded bybox_push().superfluousThese are files which are present in the destination, but not theorigin. If
deleteis set toTRUEinbox_fetch()/box_push(), they will be deleted.to_updateFiles which are present in both the origin and the destination, butwhich have more recently modified copies in the origin. If downloadingwith
box_fetch(), andoverwriteset toTRUE,new files will overwrite existing local copies. If uploading withbox_push()(andoverwriteset toTRUE), thenew version will be uploaded to box.com, with a new version number, andthe old version still being available.up_to_dateFiles present in both origin and destination, with the same content.Note: A file may be modified at later date, but if it has identicalcontents according to it's
sha1hash, it will be consideredup-to-date.box_fetch()/box_push()do nothing for thesefiles.behindFiles which are present in both origin and destination, but where thecontent differs, and the version in the destination has been morerecently updated.
box_fetch()/box_push()do nothing for thesefiles.new_foldersAnalogous to the file operation, but for directories/folders.
superfluous_foldersAnalogous to the file operation, but for directories/folders.
References
https://developer.box.com/guides/folders/
See Also
box_fetch() andbox_push(), which depend onthis internal function,file.info() for timestamps describinglocal files,digest::digest() for details of thesha1 algorithmimplementation.
Invite collaboration
Description
box_dir_invite() is deprecated in favor ofbox_collab_create().
Usage
box_dir_invite( dir_id, user_id, login = NULL, role = "viewer", can_view_path = FALSE)Arguments
dir_id |
|
user_id |
|
login |
|
role |
|
can_view_path |
|
Value
Invisiblelist().
Download/upload files from/to Box
Description
box_dl()download a file from Box to a local directory
box_ul()upload a local file to a Box folder
Usage
box_dl( file_id, local_dir = getwd(), overwrite = FALSE, file_name = NULL, version_id = NULL, version_no = NULL, pb = options()$boxr.progress, filename)box_ul( dir_id = box_getwd(), file, pb = options()$boxr.progress, description = NULL)Arguments
file_id |
|
local_dir |
|
overwrite |
|
file_name |
|
version_id |
|
version_no |
|
pb |
|
filename |
|
dir_id |
|
file |
|
description |
|
Value
box_dl()character, local path to the downloaded file.box_ul()Object with S3 class
boxr_file_reference.
Versions
box_dl() can accept one of two parameters to specify file versions:version_id orversion_no.
The box.com API refers to file versions using 11 digit ids (which can beaccessed viabox_version_history()) - you can specify theseusing theversion_id parameter.
However, this isn't terribly intuitive. As a result,box_dl()provides theversion_no parameter, which accepts a whole number,and corresponds to the versions that you'll see via the web UI. Forexample to download the version marked 'V2' on box.com, specifyversion_no = 2. This works by making an internal call tobox_version_history() to retrieve theversion_id,which makes it slightly slower.
See Also
box_fetch()andbox_push()fordirectory-wide equivalents.box_delete_file()for removinguploaded files.box_source()for R code.box_save()/box_load()for remote R objects.
Download/upload directories from/to Box
Description
box_fetch()download the contents of a Box folder to a localdirectory
box_push()upload the contents of a local directory to a Boxfolder
Files present in the origin but not the destination will becopied over.
Behavior when a file exists in both depends on the arguments supplied.
Usage
box_fetch( dir_id = box_getwd(), local_dir = getwd(), recursive = TRUE, overwrite = FALSE, delete = FALSE)box_push( dir_id = box_getwd(), local_dir = getwd(), ignore_dots = TRUE, overwrite = FALSE, delete = FALSE)Arguments
dir_id |
|
local_dir |
|
recursive |
|
overwrite |
|
delete |
|
ignore_dots |
|
Value
Object with S3 classboxr_dir_wide_operation_result.
Overwrite/Update
In the interests of preventing mishaps,overwrite is by default settoFALSE, which means that files which exist in the destination,but which are out of date, are not modified.
Settingoverwrite toTRUE is likely to produce expectedbehavior for most users.
This is a conservative precaution to prevent users unexpectedly overwritingtheir files, and may change as a default in later releases.
However, files at Box are versioned, and mostoperating systems have file recovery features (e.g. 'Trash'(Ubuntu/Debian/OSX), or 'Recycle Bin' (Windows)), so unintendedmodification of files will be revertible for most users.
Implementation
At the time of writing, the Box API allows for only one file at a timeto be uploaded/downloaded. As a result, boxr recursively scans thedirectory tree, uploading/downloading files in loops. Because the BoxAPI can send, but not accept, gzipped files, downloading tends to be fasterthan uploading.
box_fetch()/box_push() rely on the internal functionbox_dir_diff() to determine how to process individual files(i.e. which to update, which to leave as is, etc.). See its help page fordetails.
See Also
box_dl()/box_ul() for single fileoperations,box_dir_diff()determines how files should be processed
Re-authenticate to Box (interactive-app)
Description
Deletes the cached token-file before trying to re-authenticate. Thisis often the solution to authentication problems.
Usage
box_fresh_auth(cache = "~/.boxr-oauth", ...)Arguments
cache | A logical value or a string. |
... | Other arguments passed to |
Value
InvisibleNULL, called for side effects.
See Also
box_auth() for the usual method of authentication.
List files in a Box directory
Description
Non-recursive
Usage
box_ls(dir_id = box_getwd(), limit = 100, max = Inf, fields = NULL)Arguments
dir_id |
|
limit |
|
max |
|
fields |
|
Value
Object with S3 classboxr_object_list.
See Also
box_fetch() andbox_push() for synchronizing the contents oflocal and remote directories.
Get version information
Description
Superseded bybox_version_history().
Usage
box_previous_versions(file_id)Arguments
file_id |
|
Value
data.frame describing previous versions of file.
Read an R object from a Box file
Description
These functions are used to download a Box file, specified byfile_id, thenattempt to parse its contents into memory as an R object. Forexample, you may wish to read a Box CSV file as adata.frame.
Usage
box_read( file_id, type = NULL, version_id = NULL, version_no = NULL, read_fun = rio::import, ...)box_read_csv(file_id, ...)box_read_tsv(file_id, ...)box_read_json(file_id, ...)box_read_excel(file_id, ...)box_read_rds(file_id, ...)Arguments
file_id |
|
type |
|
version_id |
|
version_no |
|
read_fun |
|
... | Other arguments passed to |
Details
This is a two-step process. The first is to download the contentsof the file, the second is to parse those contents into an R object.The default parsing-function isrio::import().
In addition tobox_read(), some specific helpers areprovided:
box_read_csv()parse a remote CSV file into a
data.frame. Defaultread-function isrio::import()withformat = "csv", which usesdata.table::fread().box_read_tsv()parse a remote TSV file into a
data.frame. Defaultread-function isrio::import()withformat = "tsv", which usesdata.table::fread().box_read_json()parse a remote JSON file into a R object. Defaultread-function is
jsonlite::fromJSON().box_read_excel()parse a remote Microsoft Excel file into a
data.frame. Defaultread-function isrio::import()withformat = "excel", which usesreadxl::read_excel().box_read_rds()parse an RDS file into a R object. Uses
readRDS().
Value
Object returned by functionread_fun.
rio's import() and JSON files
In rio (0.5.18) there was a change in how JSON files are processed byrio::import(), a non-data.frame object stored in JSON is no longer coercedinto adata.frame. The old behavior would produce unexpected results or fatal errorsif the stored object was not adata.frame. The new behavior is closer to thatof the underlying functionjsonlite::fromJSON() and similar to the behavior for RDS files.
In keeping with the spirit ofjsonlite,box_read_json() has beenmodified to calljsonlite::fromJSON() directly, which by-passes the old"undesirable" behavior ofrio (< 0.5.18). If you are using the current CRANrelease ofrio (0.5.16) you should usejsonlite::read_json() to avoid these issues.
See Also
box_dl(),box_save(),box_source()
Download/upload an R workspace from/to a Box file
Description
Use these functions to save and load workspaces or collections of objectsto or from Box. Similar tosave(),save.image(), andload():these functions operate on files at Box instead of on local files.
Usage
box_save(..., dir_id = box_getwd(), file_name = ".RData", description = NULL)box_save_image( dir_id = box_getwd(), file_name = ".RData", description = NULL, filename)box_load(file_id)Arguments
... | Objects to be saved, quoted or unquoted; passed to |
dir_id |
|
file_name |
|
description |
|
filename |
|
file_id |
|
Details
box_save()Save object(s) using
save(), write to Box.box_save_image()Save workspace image using
save.image(),write to Box.box_load()Read from Box, load using
load().
Value
box_save(), box_save_image()Object with S3 class
boxr_file_reference.box_load()From
load(), a character vector of the names ofobjects created, invisibly.
See Also
Search Box files
Description
Search Box files
Usage
box_search( query = "", content_types = c("name", "description", "file_content", "comments", "tags"), type = NULL, file_extensions = NULL, ancestor_folder_ids = NULL, created_at_range = NULL, updated_at_range = NULL, size_range = NULL, trash = FALSE, owner_user_ids = NULL, max = 200)box_search_files(query, ...)box_search_folders(query, ...)box_search_trash(query, ...)Arguments
query |
|
content_types |
|
type |
|
file_extensions |
|
ancestor_folder_ids |
|
created_at_range |
|
updated_at_range |
|
size_range |
|
trash |
|
owner_user_ids |
|
max |
|
... | Other arguments passed to |
Details
The Box API supports a maximum of 200 results per request. Ifmax > 200, then multiple requests will be sent to retrieve andcombine 'paginated' results for you, behind the scenes.
See thebox.com search descriptionfor details of the features of the service.Some notable details:
Full-text searching is the default
available for many source code file types, but not R scripts.
by default Box seaches by word/token and uses the
ORoperation e.g.box_search("this that")is equivilant tobox_search("this OR that")
Reserved words for boolean operations
AND,OR, andNOT(uppercase only) are interpreted as special context e.g.box_search("NOT this"),box_search("this AND that")
Exact phrases can be matched
by surrounding them with double quotation marks e.g.
box_search('"this exact phrase"')orbox_search("\"this exact phrase\"")
Searchability is not instantaneous
it can take >10 minutes for a newly uploaded file to become findable
Value
Object with S3 classboxr_object_list.
Get/set Box default working-directory
Description
Similar togetwd() andsetwd(),these functions get and set the folder ID of the working directoryatbox.com.
This folder ID is also stored inboxr_options().
Usage
box_setwd(dir_id)box_getwd()Arguments
dir_id |
|
Value
box_getwd()numeric, ID for working folder at Box.box_setwd()invisible(NULL), called for side-effects.
See Also
box_ls() to list files in a Box directory,box_fetch()/box_push() to download/upload directories from/to Box
Source R code from a Box file
Description
Note: please use this function with extreme caution, as it ispossible for the contents of a Box file to change withoutyour knowledge.
This function downloads a file from Box, then runs itscontents, as R code, usingsource().
Usage
box_source(file_id, local = globalenv(), ...)Arguments
file_id |
|
local |
|
... | Other arguments passed to |
Value
Object returned bysource(),called for side-effect of modifying an environment.
See Also
box_dl(),box_save(),box_read()
Upload or update a file
Description
Internal functions used bybox_ul() (who's use is recommended asan alternative to these functions).
Usage
box_upload_new(dir_id, file, pb = FALSE)box_update_file(file_id, file, dir_id, pb = FALSE)Arguments
dir_id | The box.com id for the folder that you'd like to upload to |
file | A path to a file stored locally |
file_id | the box.com id of the file you'd like to update |
Details
The box.com api requires different API calls to upload a new file, and toupload a new version of a file which already exists (incrementing the versionnumber).
box_upload_new make the API call to upload a new file.box_update_file makes the API call to update an existing file.
Value
Thehttr::httr() object returned by the api call
Access Box version API
Description
Use this function to access the response-content for theversions API endpoint.
Usage
box_version_api(file_id)Arguments
file_id |
|
Value
Object with S3 class"boxr_version_list"
Get version information
Description
Box uses file versioning, but the API does not explicitly provide versionnumbers. These functions usemodified_date as a proxy to determine aversion number (version_no), which you can use withbox_dl() andbox_read().
Usage
box_version_history(file_id)box_version_number(file_id)Arguments
file_id |
|
Details
box_version_history(), previously calledbox_previous_versions(),gets information on all previous versions of a file. If there are noprevious versions, this function returnsNULL.box_version_number()gets the version number of the most-recent version.To access the Box version API itself, you can use
box_version_api().
Value
box_previous_versions()data.framedescribing previous versions of file.box_version()integerversion number of most-recent version of file.
References
This function is a light wrapper of thebox.com APIversions method.
https://developer.box.com/reference/get-files-id-versions/
See Also
box_version_api(),box_dl(),box_read()
Write an R object to a Box file
Description
Use these functions to serialize an R object and write itto a Box file. To write an object using RDS serialization,usebox_save_rds(); for other types of serialization,usebox_write() and provide a serialization function.
Usage
box_write( object, file_name, dir_id = box_getwd(), description = NULL, write_fun = rio::export, x, filename, ...)box_save_rds( object, dir_id = box_getwd(), file_name = ".RDS", description = NULL)Arguments
object | Object to be written. |
file_name |
|
dir_id |
|
description |
|
write_fun |
|
x | Object to be written,deprecated: use |
filename |
|
... | Other arguments passed to |
Details
Usingbox_save_rds() is relatively straightforward, yourobject will be written to Box as an RDS file.
If you want to specify the serialization, usebox_write().For example, you may wish to write adata.frameto Box as a CSV file. Withinbox_write(), this is atwo-step process:
serialize the contents of the R object using
write_funupload that serialization to a Box file
The default serialization-function isrio::export().
Therio::export() function currently supports onlydata.frame;to serialize lists, you may wish to usejsonlite::toJSON().
Please note thatbox_write() is used to write R objects to Box filesusing standard formats. To write R objects as.RData files,you can usebox_save().
Value
Object with S3 classboxr_file_reference.
See Also
boxr S3 Classes
Description
boxr implements a series of S3 classes to manage the data returned by theBox API. These classes are built onlist; if you wish to access theinformation directly, you can useunclass(x).
Details
boxr_file_reference
describes a file created, modified, or deleted at Box.
returned by
box_ul(),box_save(),box_delete_file(), etc.available methods:
print().
boxr_folder_reference
describes a folder created or deleted at Box.
returned by
box_dir_create(),box_delete_folder().available methods:
print().
boxr_dir_wide_operation_result
describes the result of a directory-wide operation.
returned by
box_fetch()andbox_push().
boxr_object_list
describes a collection of files at Box.
returned by
box_ls(),box_search(), and related functions.available methods:
print(),as.data.frame().
boxr_dir_comparison
describes the difference between directories.
returned by the internal function
box_dir_diff().
boxr_collab
describes a collaboration (sharing permission).
returned by
box_collab_create().available methods:
print(),as.data.frame(),tibble::as_tibble().
boxr_collab_list
describes a collection of collaborations.
returned by
box_collab_get().available methods:
print(),as.data.frame(),tibble::as_tibble().
boxr_comment
describes a comment on a file.
returned by
box_comment_create().available methods:
print(),as.data.frame(),tibble::as_tibble().
boxr_comment_list
describes a collection of comments on a file.
returned by
box_comment_get().available methods:
print(),as.data.frame(),tibble::as_tibble().
boxr_version_list
describes a collection of version information on a file.
returned by
box_version_api().available methods:
print(),as.data.frame(),tibble::as_tibble().
Get boxr options
Description
This function gets the values of boxr's global options.
Usage
boxr_options()Details
Options can be set in the usual way, usingoptions().
Value
list, current values of boxr options, with elements:
boxr.interactivelogical, indicates if boxr is running in interactive mode.boxr.progresslogical, indicates to use progress-bars, if available.boxr.verboselogical, indicates if boxr will usecat()to print to the console.Setting toTRUEmay cause problems withknitr.boxr.wdlist, containing information on the Box working-directory:id(numeric), andname(character).boxr.wd.pathcharacter, path to the Box working-directory.boxr.tokenObject with S3 class
Token2.0(httr::Token2.0).boxr_token_jwtObject with S3 class
request(httr::request).boxr.print_tibblelogical, indicates to print as tibble where available.
Create a data.frame of metadata of the contents of a local directory
Description
Create a data.frame of metadata of the contents of a local directory
Usage
create_loc_dir_df(local_dir = getwd())Arguments
local_dir | The local directory which you'd like |
Value
A data.frame of metadata.
Single Directory Operations for Downloading and Uploading multiple Files
Description
Download or upload the contents of a box.com directory, not includingsubdirectories
Usage
deleteRemoteObjects(dir_id, local_dir = getwd())downloadDirFiles( dir_id, local_dir = getwd(), overwrite = TRUE, dir_str = getwd())uploadDirFiles(dir_id, local_dir = getwd(), overwrite = TRUE)Arguments
dir_id | The box.com id for the folder that you'd like to query |
local_dir | The local directory which you'd like |
Value
TRUE for a successful sync,NULL if the box.com folderis empty.
Obtain a data.frame of the sub-directories in a box.com folder
Description
Takes theid of a box folder and returns a data.frame of it'ssubdirectories, including their equivalent paths in the local directory.
Usage
dirTreeRecursive(dir_id, local_dir = getwd())Arguments
dir_id | The box.com id for the folder that you'd like to query |
local_dir | The local directory which you'd like |
Value
A data.frame describing the contents directory structure of thebox.com folder corresponding todir_id.