Hello!
I’m using the /api/v2/assets/{uid}/data/{id}/
API to retrieve submissions and donwload attachments.
I’ve noticed that the logic to link attachments with their related question is a bit unclear… here’s an example submission record retrived from the API, with just 2 form questions of type image, and the 2 related attachments:
{
"_id": 166455,
...
"picture": "1634129991832.jpg",
"idcard": "1634130005204.jpg",
"_attachments": [
{
"download_url": "https://kobo.oneacrefund.org/api/v2/assets/aPLzYdDLMufaRtECGzB7o4/data/166455/attachments/original/?media_file=yann_jouanique%2Fattachments%2Fc20e20f69b6047c1bfe6ae244bf51a6d%2Fd9c5ad6a-2949-4c61-b248-c38ad43d3520%2F1634130005204.jpg",
"download_large_url": "https://kobo.oneacrefund.org/api/v2/assets/aPLzYdDLMufaRtECGzB7o4/data/166455/attachments/large/?media_file=yann_jouanique%2Fattachments%2Fc20e20f69b6047c1bfe6ae244bf51a6d%2Fd9c5ad6a-2949-4c61-b248-c38ad43d3520%2F1634130005204.jpg",
"download_medium_url": "https://kobo.oneacrefund.org/api/v2/assets/aPLzYdDLMufaRtECGzB7o4/data/166455/attachments/medium/?media_file=yann_jouanique%2Fattachments%2Fc20e20f69b6047c1bfe6ae244bf51a6d%2Fd9c5ad6a-2949-4c61-b248-c38ad43d3520%2F1634130005204.jpg",
"download_small_url": "https://kobo.oneacrefund.org/api/v2/assets/aPLzYdDLMufaRtECGzB7o4/data/166455/attachments/small/?media_file=yann_jouanique%2Fattachments%2Fc20e20f69b6047c1bfe6ae244bf51a6d%2Fd9c5ad6a-2949-4c61-b248-c38ad43d3520%2F1634130005204.jpg",
"mimetype": "image/jpeg",
"filename": "yann_jouanique/attachments/c20e20f69b6047c1bfe6ae244bf51a6d/d9c5ad6a-2949-4c61-b248-c38ad43d3520/1634130005204.jpg",
"instance": 166455,
"xform": 151,
"id": 57707
},
{
"download_url": "https://kobo.oneacrefund.org/api/v2/assets/aPLzYdDLMufaRtECGzB7o4/data/166455/attachments/original/?media_file=yann_jouanique%2Fattachments%2Fc20e20f69b6047c1bfe6ae244bf51a6d%2Fd9c5ad6a-2949-4c61-b248-c38ad43d3520%2F1634129991832_0OdlaKJ.jpg",
"download_large_url": "https://kobo.oneacrefund.org/api/v2/assets/aPLzYdDLMufaRtECGzB7o4/data/166455/attachments/large/?media_file=yann_jouanique%2Fattachments%2Fc20e20f69b6047c1bfe6ae244bf51a6d%2Fd9c5ad6a-2949-4c61-b248-c38ad43d3520%2F1634129991832_0OdlaKJ.jpg",
"download_medium_url": "https://kobo.oneacrefund.org/api/v2/assets/aPLzYdDLMufaRtECGzB7o4/data/166455/attachments/medium/?media_file=yann_jouanique%2Fattachments%2Fc20e20f69b6047c1bfe6ae244bf51a6d%2Fd9c5ad6a-2949-4c61-b248-c38ad43d3520%2F1634129991832_0OdlaKJ.jpg",
"download_small_url": "https://kobo.oneacrefund.org/api/v2/assets/aPLzYdDLMufaRtECGzB7o4/data/166455/attachments/small/?media_file=yann_jouanique%2Fattachments%2Fc20e20f69b6047c1bfe6ae244bf51a6d%2Fd9c5ad6a-2949-4c61-b248-c38ad43d3520%2F1634129991832_0OdlaKJ.jpg",
"mimetype": "image/jpeg",
"filename": "yann_jouanique/attachments/c20e20f69b6047c1bfe6ae244bf51a6d/d9c5ad6a-2949-4c61-b248-c38ad43d3520/1634129991832_0OdlaKJ.jpg",
"instance": 166455,
"xform": 151,
"id": 57706
}
]
}
As you can see, the value for the 2 image questions is a file name, which I expect can be mapped to one of the attachments’ filename.
However, while the filename for the idcard
question (1634130005204.jpg
) clearly points to the first attachment in the _attachments
array, the one for the picture
form question (1634129991832.jpg
) does not really clearly point to the second attachment, whose filename is in fact 1634129991832_0OdlaKJ.jpg
… The prefix is the same, but the attachment has a suffix that makes the mapping difficult, and more importantly, ambiguous: I’ve seen submissions with multiple attachments with the same prefix (and therefore with more attachments than therer are attachment-based questions in the form)… In this case, how to disambiguate and identify which is the right one?
Most submissions are unambiguous, and I’m not certain how the ambiguities pop up - I suspect this happens when the data collector made several picture attempts (?).
Can someone help clarify the logic here?