osfr (version 0.2.4)

osf_download: Download files and directories from OSF

Description

Files stored on OSF can be downloaded locally by providing an osf_tbl_file that contains the OSF file of interest. If the osf_tbl_file contains a directory, a zip file containing the directory's contents will be downloaded.

By default files are downloaded to your current working directory with the same filename used on OSF. The path argument can be used to specify a different destination and, optionally, a different filename for the downloaded file. Note, the directory portion of path must reference an existing directory.

Usage

osf_download(x, path = NULL, overwrite = FALSE, verbose = FALSE)

Arguments

x

An osf_tbl_file containing a single file or directory.

path

Local path where the downloaded file will be saved. The default is to use the remote file's name.

overwrite

Logical, if the local path already exists should it be replaced with the downloaded file?

verbose

Logical, indicating whether to print informative messages about interactions with the OSF API (default FALSE).

Value

The osf_tbl_file input with a new column, "local_path", containing the downloaded file's path.

See Also

Examples

Run this code
# NOT RUN {
# download a single file
analysis_plan <- osf_retrieve_file("2ryha") %>%
  osf_download(path = "plan_wave1.docx")

# verify the file was downloaded locally
file.exists(analysis_plan$local_path)
# }

Run the code above in your browser using DataLab