# NOT RUN {
> #*** 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])
>
>
> #* Export a single file
> exportFiles(rcon, record=1, field="file_upload", event="event_1_arm_1")
The file was saved to '1-event_1_arm_1-NewOutcomes.xlsx'
>
>
> #* Export all files in a project
> #* Although this example only shows one field for files, it could work with
> #* an arbitrary number of file upload fields
> library(reshape2)
> Data <- exportRecords(Data)
> (filesToExport <- melt(Data[, c("id", "redcap_event_name", "file_upload")],
c("id", "redcap_event_name")),
na.rm=TRUE)
id redcap_event_name variable value
1 1 event_1_arm_1 file_upload [document]
4 2 event_1_arm_1 file_upload [document]
>
> for(i in 1:nrow(filesToExport)){
+ exportFiles(rcon, record=filesToExport$id[i],
+ field=filesToExport$variable[i],
+ event=filesToExport$redcap_event_name[i])
+ }
The file was saved to '1-event_1_arm_1-NewOutcomes.xlsx'
The file was saved to '2-event_1_arm_1-Sunset2.JPG'
# }
Run the code above in your browser using DataLab