Functions to download (box_dl), and upload (box_ul).

  • box_dl takes the id of a file hosted on box.com, downloads it and writes it to disk.

  • box_ul uploads a file stored locally to a specified box.com folder. If a file with the same name already exists, it will upload the file as a new version.

box_dl(file_id, local_dir = getwd(), overwrite = FALSE,
  filename = NULL, version_id = NULL, version_no = NULL,
  pb = options()$boxr.progress)

box_ul(dir_id = box_getwd(), file, pb = options()$boxr.progress,
  description = NULL)

Arguments

file_id

The box.com id for the file that you'd like to download

local_dir

A file path to a local directory which you'd like the file to be downloaded to.

overwrite

logical. Should existing files with the same name be overwritten?

filename

Optional. An alternate filename for the local version of the file. The default, NULL, uses the name from box.com.

version_id

If downloading an older version, the version_id of the desired file

version_no

The version of the file you'd like to download (starting at 1)

pb

Should a progress bar be shown? (via setTxtProgressBar())

dir_id

If uploading, the box.com folder id that you'd like to upload to.

file

the path to the local file that you'd like to upload (if there is one)

description

Optional. character. A string to be used as the description caption for the file (added via box_add_description()). Useful for describing the contents of a file, or describing the latest changes made to it. If NULL (the default), no description is added.

Value

box_dl returns the path of the newly downloaded file if successful, and throw an error otherwise.

box_ul will return an object of class boxr_file_reference.

Versions

box_dl can accept one of two parameters to specify file versions: version_id and version_no.

The box.com API refers to file versions using 11 digit ids (which can be accessed via box_previous_versions()) - you can specify these using the version_id parameter.

However, this isn't terribly intuitive. As a result, box_dl provides the version_no parameter, which accepts a whole number, and corresponds to the versions that you'll see via the web UI. For example to download the version marked 'V2' on box.com, specify version_no = 2. This works by making an internal call to box_previous_versions() to retrieve the version_id, which makes it slightly slower.

See also