Movatterモバイル変換


[0]ホーム

URL:


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 LyttleORCID iD [aut, cre], Nathan DayORCID iD [aut], Vincent Fulco [ctb], Alec Wong [ctb], Alex Brodersen [ctb]
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:

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:

Other contributors:

See Also

Useful links:


Pipe operator

Description

Seemagrittr::%>% for details.

Usage

lhs %>% rhs

Issue 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

numeric orcharacter, file ID at Box.

description

character, description caption for the file.

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():

  1. Connecting tobox.comaccounts fromboxr for the first time.

  2. 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

character,the client id for the account to use.

client_secret

character,the client secret for the account to use.

interactive

logical, indicates that the authorization processwill be interactive (requiring user input to the R console, and/or avisit tobox.com).

cache

A logical value or a string.TRUE means to cacheusing the default cache file.httr-oauth,FALSE meansdon't cache, andNA means to guess using some sensible heuristics.A string means use the specified path as the cache file.

write.Renv

deprecated.

...

Other arguments passed tohttr::oauth2.0_token().

Value

InvisibleNULL, called for side effects.

Side-effects

This function has some side effects which make subsequent calls tobox_auth() easier:

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

[Deprecated]

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

logical, indicates if boxr should authenticateas soon as it's loaded.

Value

InvisibleNULL, called for side effects.

Note

This is provided for convenience, but it's a bad idea to use, if:

See Also

box_auth()


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:

Usage

box_auth_service(token_file = NULL, token_text = NULL)

Arguments

token_file

character, path to JSON token-file. If not provided,the function will look for an environment variableBOX_TOKEN_FILE. Ifthat is not there, it will try⁠~/.boxr-auth/token.json⁠.

token_text

character, JSON text. If this is provided,token_file is ignored.

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:

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

numeric orcharacter, folder ID at Box.

file_id

numeric orcharacter, file ID at Box.

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:

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

numeric orcharacter, folder ID at Box.

user_id

character ID for Box user-account to invite.

file_id

numeric orcharacter, file ID at Box.

group_id

character ID for Box group-account to invite.

login

character email address of account to invite, if specifiedwill be used instead ofuser_id.

role

character role of the collaborator; default is"viewer".

can_view_path

logical indicates to allow the collaborator tonavigate parent-folders at Box.

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

box_auth(),box_auth_service()


Delete Box collaboration

Description

Delete Box collaboration

Usage

box_collab_delete(collab_id)

Arguments

collab_id

character ID for Box collaboration

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

numeric orcharacter, folder ID at Box.

file_id

numeric orcharacter, file ID at Box.

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

numeric orcharacter, file ID at Box.

message

character contents of comment.Note: tagging people with the @user pattern isnot yet supported.

comment_id

numeric orcharacter, comment ID at Box.

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 classboxr_comment.

box_comment_get()

Object with S3 classboxr_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

numeric orcharacter, file ID at Box.

dir_id

numeric orcharacter, folder ID at Box.

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()

InvisibleNULL, called for side effects.

box_restore_file()

Object with S3 classboxr_file_reference.

box_delete_folder()

InvisibleNULL, called for side effects.

box_restore_folder()

Object with S3 classboxr_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

character, name for new folder at Box.

parent_dir_id

character ornumeric,ID for the parent folder at Box.

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

logical. Should the results be in the context of an uploador a download operation? Permitted values are"up" or"down"

folders

logical. Should folders/directories be included in theresult?

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'ssha1hash, 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; themtimevariable returned byfile.info().

For remote files, themodified_at date 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:

new

Files which are present in the origin, but not the destination. Thesewill be downloaded bybox_fetch()/uploaded bybox_push().

superfluous

These are files which are present in the destination, but not theorigin. Ifdelete is set toTRUE inbox_fetch()/box_push(), they will be deleted.

to_update

Files which are present in both the origin and the destination, butwhich have more recently modified copies in the origin. If downloadingwithbox_fetch(), andoverwrite set toTRUE,new files will overwrite existing local copies. If uploading withbox_push() (andoverwrite set toTRUE), thenew version will be uploaded to box.com, with a new version number, andthe old version still being available.

up_to_date

Files 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'ssha1 hash, it will be consideredup-to-date.box_fetch()/box_push() do nothing for thesefiles.

behind

Files 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_folders

Analogous to the file operation, but for directories/folders.

superfluous_folders

Analogous 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

[Deprecated]

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

numeric orcharacter, folder ID at Box.

user_id

character ID for Box user-account to invite.

login

character email address of account to invite, if specifiedwill be used instead ofuser_id.

role

character role of the collaborator; default is"viewer".

can_view_path

logical indicates to allow the collaborator tonavigate parent-folders at Box.

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

numeric orcharacter, file ID at Box.

local_dir

character, path to local directory.

overwrite

logical, indicates that newer files at origin willoverwrite older files at destination.

file_name

character, if supplied, an alternate filenamefor the local version of the Box file.

version_id

character ornumeric, theversion_id of the file.

version_no

numeric, version of the file you'd like to download(starting at 1).

pb

logical, indicates to show progress bar(viasetTxtProgressBar()).

filename

character,deprecated: usefile_name instead.

dir_id

numeric orcharacter, folder ID at Box.

file

character, local path to the file.

description

character, description caption for the file.

Value

box_dl()

character, local path to the downloaded file.

box_ul()

Object with S3 classboxr_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


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

numeric orcharacter, folder ID at Box.

local_dir

character, path to local directory.

recursive

logical, indicates to include subdirectories.

overwrite

logical, indicates that newer files at origin willoverwrite older files at destination.

delete

logical, indicates to delete files that exist at destination,but not at origin.

ignore_dots

logical, indicates to ignore directories with namesthat begin with dots, e.g..git and.Rproj.user.

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.TRUE means to cacheusing the default cache file.httr-oauth,FALSE meansdon't cache, andNA means to guess using some sensible heuristics.A string means use the specified path as the cache file.

...

Other arguments passed tobox_auth().

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

numeric orcharacter, folder ID at Box.

limit

integer, maximum number of entries to retrieve per query-page.

max

integer, maximum number of entries to retrieve in total.

fields

character, fields to return; the defaultvalue,NULL, will return all possible fields from API:modified_at,content_modified_at,name,id,type,sha1 ,size,owned_by,path_collection,description,file_version.

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]

Superseded bybox_version_history().

Usage

box_previous_versions(file_id)

Arguments

file_id

numeric orcharacter, file ID at Box.

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

numeric orcharacter, file ID at Box.

type

character,MIME typeused to override the content type returned by the server.

version_id

character ornumeric, theversion_id of the file.

version_no

numeric, version of the file you'd like to download(starting at 1).

read_fun

function, used to read (parse) the content into R; forbox_read()the default function isrio::import(); the specific helperseach use a different function directly.

...

Other arguments passed toread_fun.

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 adata.frame. Defaultread-function isrio::import() withformat = "csv", which usesdata.table::fread().

box_read_tsv()

parse a remote TSV file into adata.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 isjsonlite::fromJSON().

box_read_excel()

parse a remote Microsoft Excel file into adata.frame. Defaultread-function isrio::import() withformat = "excel", which usesreadxl::read_excel().

box_read_rds()

parse an RDS file into a R object. UsesreadRDS().

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 tosave().

dir_id

numeric orcharacter, folder ID at Box.

file_name

character, if supplied, an alternate filenamefor the local version of the Box file.

description

character, description caption for the file.

filename

character,deprecated: usefile_name instead.

file_id

numeric orcharacter, file ID at Box.

Details

box_save()

Save object(s) usingsave(), write to Box.

box_save_image()

Save workspace image usingsave.image(),write to Box.

box_load()

Read from Box, load usingload().

Value

⁠box_save(), box_save_image()⁠

Object with S3 classboxr_file_reference.

box_load()

Fromload(), a character vector of the names ofobjects created, invisibly.

See Also

save(),save.image(),load()


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

character, search term.

content_types

character, content to search; more than onecan be supplied with a vector.

type

character, type of object to return; the default,NULL, returns all possible types ("file","folder", or"weblink").

file_extensions

character, vector of strings containing the fileextensions (without dots) by which to narrow your search.

ancestor_folder_ids

numeric orcharacter, if supplied,results are limited to one or more parent (ancestor) folders.

created_at_range

POSIXct (vector, length 2),range of created-at times.

updated_at_range

POSIXct (vector, length 2),range of updated-at times.

size_range

numeric (vector, length 2),range of file sizes (bytes).

trash

logical, indicates to search only the trash folder.

owner_user_ids

numeric orcharacter, limits search to files ownedby users with these IDs.

max

numeric, upper limit on the number of search results.

...

Other arguments passed tobox_search().

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:

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

numeric orcharacter, folder ID at Box.

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

numeric orcharacter, file ID at Box.

local

TRUE,FALSE or an environment, determiningwhere the parsed expressions are evaluated.FALSE (thedefault) corresponds to the user's workspace (the globalenvironment) andTRUE to the environment from whichsource is called.

...

Other arguments passed tosource().

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

numeric orcharacter, file ID at Box.

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

numeric orcharacter, file ID at Box.

Details

Value

box_previous_versions()

data.frame describing previous versions of file.

box_version()

integer version 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

character, name of the new Box file.

dir_id

numeric orcharacter, folder ID at Box.

description

character, description caption for the file.

write_fun

function, used to write (serialize) the content from R;default function isrio::export().

x

Object to be written,deprecated: useobject instead.

filename

character,deprecated: usefile_name instead.

...

Other arguments passed towrite_fun.

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:

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

saveRDS(),box_save()


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

boxr_folder_reference

boxr_dir_wide_operation_result

boxr_object_list

boxr_dir_comparison

boxr_collab

boxr_collab_list

boxr_comment

boxr_comment_list

boxr_version_list


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.interactive

logical, indicates if boxr is running in interactive mode.

boxr.progress

logical, indicates to use progress-bars, if available.

boxr.verbose

logical, indicates if boxr will usecat() to print to the console.Setting toTRUE may cause problems withknitr.

boxr.wd

list, containing information on the Box working-directory:id(numeric), andname(character).

boxr.wd.path

character, path to the Box working-directory.

boxr.token

Object with S3 classToken2.0 (httr::Token2.0).

boxr_token_jwt

Object with S3 classrequest (httr::request).

boxr.print_tibble

logical, 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 likedir_id tocorrespond to. If you're not interested in mapping local to hosteddirectories, this isn't terribly important.

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 likedir_id tocorrespond to. If you're not interested in mapping local to hosteddirectories, this isn't terribly important.

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 likedir_id tocorrespond to. If you're not interested in mapping local to hosteddirectories, this isn't terribly important.

Value

A data.frame describing the contents directory structure of thebox.com folder corresponding todir_id.


[8]ページ先頭

©2009-2025 Movatter.jp