View source: R/cto_form_data_attachment.R
| cto_form_data_attachment | R Documentation |
Extracts attachment URLs (images, audio, video, signatures) from SurveyCTO form data and downloads the files to a local directory. This function handles encrypted forms if a private key is provided.
cto_form_data_attachment(
form_id,
fields = everything(),
private_key = NULL,
dir = file.path(getwd(), "media"),
overwrite = FALSE
)
form_id |
A string specifying the SurveyCTO form ID to inspect. |
fields |
A |
private_key |
Optional. A character string specifying the path to a local RSA private key file. Required if the form is encrypted. |
dir |
A character string specifying the local directory where files should be saved.
Defaults to |
overwrite |
Logical. If |
This function performs the following steps:
Fetches the form data using cto_form_data.
Scans the selected fields for values matching the standard SurveyCTO API
attachment URL pattern.
Downloads the identified files sequentially to the specified dir.
Returns a vector of file paths (invisibly). The function is called for its side effect of downloading files to the local disk.
Other Form Management Functions:
cto_form_attachment(),
cto_form_data(),
cto_form_dofile(),
cto_form_languages(),
cto_form_metadata()
## Not run:
# 1. Download all attachments from the form submissions
cto_form_data_attachment(
form_id = "household_survey_v1",
dir = "downloads/medias"
)
# 2. Download only specific image fields from an encrypted form
cto_form_data_attachment(
form_id = "encrypted_health_survey",
fields = starts_with("image_"),
private_key = "keys/my_priv_key.pem",
overwrite = TRUE
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.