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

View source: R/docsFromFileRepository.R

fromFileRepositoryMethodsR Documentation

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 class 'redcapApiConnection'
exportFromFileRepository(rcon, doc_id, dir = getwd(), dir_create = FALSE, ...)

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

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

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

Details

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

Value

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

directory The directory in which the file is saved.
filename The name of the saved file.

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.

See Also

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

Examples

## Not run: 
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)

## End(Not run)
  

redcapAPI documentation built on Oct. 17, 2024, 5:07 p.m.