Learn R Programming

redcapAPI (version 1.1)

importFiles: Imports a File to Attach to a Record

Description

A single file may be attached to a single record. The behavior of this function is consistent with the behavior of the API, which only allows one file to be uploaded at a time.

Usage

## S3 method for class 'redcapDbConnection':
importFiles(rcon, file, record, field, event, overwrite=TRUE, ...,
    proj=NULL)
## S3 method for class 'redcapApiConnection':
importFiles(rcon, file, record, field, event, overwrite=TRUE, ...,
    proj=NULL)

Arguments

rcon
A REDCap connection object as generated by redcapConnection
file
Character string giving the file path to the file to be imported.
record
The record ID in which the desired file is stored. Must be length 1.
field
The field name in which the file is stored. Must be length 1.
event
The event name for the file. Must be length 1. This applies only to longitudinal projects. If the event is not supplied for a longitudinal project, the API will return an error
overwrite
Logical. 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.
proj
A redcapProject object as created by redcapProjectInfo.
...
Arguments to be passed to other methods

Details

The function may only import a single file.

References

Please refer to your institution's API documentation.

Additional details on API parameters are found on the package wiki at https://github.com/nutterbAPI/redcap/wiki/REDCap-API-Parameters

Examples

Run this code
> #*** Note: I cannot provide working examples without
> #*** compromising security.  Instead, I will try to 
> #*** offer up sample code with the matching results
> 
> #*** Create the connection object
> rcon <- redcapConnection(url=[YOUR_REDCAP_URL], token=[API_TOKEN])
> 
>
> #* Import a single file
> importFiles(rcon, "Image.jpg", record=1, field="file_upload", event="event_1_arm_1")
The file was successfully uploaded
>

Run the code above in your browser using DataLab