%%capture
%%R
redcap_file_download_oneshot(= "case_intake_arm_1",
event = "./files/export_files/",
directory = "test_file_export_r.png",
file_name = 1,
record = "test_upload",
field = url,
redcap_uri = token,
token = TRUE
overwrite )
10 Files
File uploads (attachments to individual records) are a unique field type in REDCap that accept a variety of file types, including images, pdfs, and many more. Unlike other export methods, exporting files only works for one file field from one record at a time.
If the project has repeating events (i.e. a longitudinal project), the event name that the record is in must be specified. If the file of interest is in a repeat instance, the instance number must also be specified.
In this example we will download the test file from record 1 in the test_upload
field in case_intake_arm_1
event, and save the file to a specified location.
redcap_file_download_oneshot()
export_file()
In python we will use the IPython.diplay
module to view the downloaded file.
= project.export_file(record="1",
export_file_image ="test_upload",
field="case_intake_arm_1")
eventwith open("files/export_files/test_file_export_py.png","wb") as binary_file:
0]) binary_file.write(export_file_image[
from IPython.display import Image
"files/export_files/test_file_export_py.png", width=300) Image(