if (FALSE) {
# Define some constants
uri <- "https://bbmc.ouhsc.edu/redcap/api/"
token <- "D70F9ACD1EDD6F151C6EA78683944E98" # The simple project -pid 213
field <- "mugshot"
event <- "" # only for longitudinal events
# Upload a single image file.
record <- 1
file_path <- system.file("test-data/mugshot-1.jpg", package = "REDCapR")
REDCapR::redcap_file_upload_oneshot(
file_name = file_path,
record = record,
field = field,
redcap_uri = redcap_uri,
token = token
)
# Upload a collection of five images.
records <- 1:5
file_paths <- system.file(
paste0("test-data/mugshot-", records, ".jpg"),
package="REDCapR"
)
for (i in seq_along(records)) {
record <- records[i]
file_path <- file_paths[i]
REDCapR::redcap_file_upload_oneshot(
file_name = file_path,
record = record,
field = field,
redcap_uri = redcap_uri,
token = token
)
}
}
Run the code above in your browser using DataLab