Learn R Programming

redcapAPI (version 2.10.0)

fromFileRepositoryMethods: Export, Import, and Delete Individual Files from the File Repository

Description

These methods enable the user to export, import, or delete individual files from a REDCap project's file repository.

Usage

exportFromFileRepository(rcon, doc_id, dir = getwd(), dir_create = FALSE, ...)

importToFileRepository(rcon, file, folder_id = numeric(0), ...)

deleteFromFileRepository(rcon, doc_id, ...)

# S3 method for redcapApiConnection exportFromFileRepository(rcon, doc_id, dir = getwd(), dir_create = FALSE, ...)

# S3 method for redcapApiConnection importToFileRepository(rcon, file, folder_id = numeric(0), ...)

# S3 method for redcapApiConnection deleteFromFileRepository(rcon, doc_id, ...)

Value

exportFromFileRepository, importToFileRepository, and deleteFromFileRepository each return a data frame with the columns:

directoryThe directory in which the file is saved.
filenameThe name of the saved file.

Arguments

rcon

A redcapConnection object.

doc_id

integerish(1). The document ID to be downloaded.

folder_id

integerish(0/1). The ID of the folder into which the file is to be imported. If length is zero, it is imported to the top-level folder.

file

character(1). A file on the local system to be imported to the File Repository.

dir

character(1). A directory on the local system to which the file is to be saved. Defaults to the working directory.

dir_create

logical(1). Create the directory dir if it does not already exist. Defaults to FALSE. If dir does not exist and create = FALSE, an error is thrown.

...

Arguments to pass to other methods

Functions

  • exportFromFileRepository(): Export a file from the file repository.

  • importToFileRepository(): Import a file to the file repository.

  • deleteFromFileRepository(): Delete a file from the file repository.

Details

When a file is deleted, the file will remain in the Recycle Bin folder for up to 30 days.

See Also

exportFileRepository(),
importFileRepository(),
deleteFileRepository(),
exportFileRepositoryListing(),
createFileRepositoryFolder()

Examples

Run this code
if (FALSE) {
unlockREDCap(connections = c(rcon = "project_alias"), 
             url = "your_redcap_url", 
             keyring = "API_KEYs", 
             envir = globalenv())
             
 
write_to_path <- tempdir()            
             
# Export a file from the repository
exportFromFileRepository(rcon, 
                         doc_id = 12345, 
                         dir = write_to_path)
                         
# Export a file and create the target directory if it does not exist
exportFromFileRepository(rcon, 
                         doc_id = 12345, 
                         dir = write_to_path, 
                         dir_create = TRUE)
                         
# Import a file to the top-level directory of the file repository
importFileToRepository(rcon, 
                       file = "file_to_import.txt")
                       
# Import a file to a specific directory of the file repository
importFileToRepository(rcon, 
                       file = "file_to_import.txt", 
                       folder_id = 678)
                       
# Delete a file from the file repository
deleteFileFromRepository(rcon, 
                         doc_id = 12345)
}
  

Run the code above in your browser using DataLab