Learn R Programming

redcapAPI (version 2.8.0)

fileMethods: Export, Import, or Delete Files to a Field in a REDCap Project

Description

These methods enable to the user to export a file stored in a project field, import a file, or delete an existing file.

Usage

exportFiles(rcon, record, field, event = NULL, dir, file_prefix = TRUE, ...)

importFiles( rcon, file, record, field, event, overwrite = TRUE, repeat_instance = NULL, ... )

deleteFiles(rcon, record, field, event, ...)

# S3 method for redcapApiConnection exportFiles( rcon, record, field, event = NULL, dir, file_prefix = TRUE, repeat_instance = NULL, ..., error_handling = getOption("redcap_error_handling"), config = list(), api_param = list() )

# S3 method for redcapApiConnection importFiles( rcon, file, record, field, event = NULL, overwrite = TRUE, repeat_instance = NULL, ..., error_handling = getOption("redcap_error_handling"), config = list(), api_param = list() )

# S3 method for redcapApiConnection deleteFiles( rcon, record = NULL, field = NULL, event = NULL, repeat_instance = NULL, ..., error_handling = getOption("redcap_error_handling"), config = list(), api_param = list() )

Value

exportFiles has no return and displays a message with file path to which the exported file was saved.

importFiles has no return and displays a message indicating whether the import was successful.

deleteFiles has no return and displays a message indicating whether the file was successfully deleted from the project.

Arguments

rcon

A redcapConnection object.

record

character(1) or integerish(1). The record ID in which the desired file is stored.

field

character(1). The field name in which the file is stored.

event

character(1) or NULL. The event name for the file. This applies only to longitudinal projects. If the event is not supplied for a longitudinal project, the API will return an error message

repeat_instance

integerish(1) or NULL. The repeat instance number of the repeating event or the repeating instrument. When available in your instance of REDCap, and passed as NULL, the API will assume a value of 1.

file

character(1). The file path to the file to be imported.

overwrite

logical(1). When FALSE, the function checks if a file already exists for that record. If a file exists, the function terminates to prevent overwriting. When TRUE, no additional check is performed.

dir

character(1). A directory/folder to which the file will be saved. By default, the working directory is used.

file_prefix

logical(1). Determines if a prefix is appended to the file name. The prefix takes the form [record_id]-[event_name]-[file_name]. The file name is always the same name of the file as it exists in REDCap.

...

Arguments to pass to other methods

error_handling

character(1). One of c("error", "null"). An option for how to handle errors returned by the API. see redcapError().

config

A named list. Additional configuration parameters to pass to httr::POST(). These are appended to any parameters in rcon$config.

api_param

A named list. Additional API parameters to pass into the body of the API call. This provides users to execute calls with options that may not otherwise be supported by redcapAPI.

Functions

  • exportFiles(): Export a file from a REDCap project.

  • importFiles(): Import a file to a REDCap project.

  • deleteFiles(): Delete a file from a REDCap project.

Details

These functions only export, import, or delete a single file.

When exporting, the file cannot be changed; whatever name exists in REDCap is the name that will be used. The record ID and event name may be appended as a prefix.