While adding videos in my form in CHT, I noticed that medic-conf fails to compile when the total video size in the form media folder is 16MB or above. Is there max size limit for uploading videos?
CHT Version: 3.13
Error:
ERROR FetchError: invalid json response body at https://medic.local:4430/medic/form%3Avideos_test reason: Unexpected token < in JSON at position 0
at /home/user/nodeV12/lib/node_modules/cht-conf/node_modules/pouchdb-fetch/node_modules/node-fetch/lib/index.js:272:32
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:93:5)
I believe we’ve come across crashes when forms have large image attachments (6MB in this particular case). This however never happened when uploading the resources but when the phone was downloading them to and saving them in PouchDB.
I’m not aware of any hard size limits.
Are you able to split your video into multiple parts? Has it been optimised to match your phone’s resolution (it would also help with reducing the file size)
Can you please share at which point does cht-conf fail? What command are you running?
Could you also check your API logs and see if there’s anything suspicious there?
I’m partially suspecting a request timeout that returns HTML instead of json.
I have been able to add videos to a form that are 22MB and 18MB in size. When I tried to upload both at the same time I got the error below which leads me to suspect there might be an issue with your form. Are you able to share the form’s xml file?
ERROR {
"code": 413,
"error": "Payload Too Large",
"status": 413,
"name": "Payload Too Large",
"docId": "form:video_test"
}
I am still unable to replicate your issue. I still see the error I posted above when the video files are too large. I am using cht-conf version 3.9.2 locally. Which version are you running? You find out the version by running cht --version.
In the mean time maybe you can try adding the videos to the form using couchdb.
They are not lazy loaded, they required being replicated (downloaded) at boot time and downloaded every time the form is edited. They are stored directly in IndexedDb, this is the browser storage and do consume app internal storage.
Hi @diana
I encountered the same issue regarding video size. I’m attempting to upload an infant_child form with a total video size of 22.7MB, which is below the 32MB limit:
However, I received the following error indicating that the entity is too large:
steve@Steve-coder:~/Documents/cht-work/jamii-ni-afya$ cht --url=https://medic:****@cht-dev.d-tree.org/ convert-app-forms upload-app-forms -- infant_child
INFO Checking that https://medic:****@cht-dev.d-tree.org/medic/ is available...
INFO Processing config in jamii-ni-afya.
INFO Actions:
- convert-app-forms
- validate-app-forms
- upload-app-forms
INFO Starting action: convert-app-forms…
INFO Converting form /home/steve/Documents/cht-work/jamii-ni-afya/forms/app/infant_child.xlsx
INFO convert-app-forms complete.
INFO Starting action: validate-app-forms…
INFO Validating form: infant_child.xml…
INFO validate-app-forms complete.
INFO Starting action: upload-app-forms…
INFO Preparing form for upload: infant_child.xml…
INFO {
"type": "ERROR",
"error": "413 Request Entity Too Large",
"server": "nginx",
"status": 413,
"name": "413 Request Entity Too Large",
"stack": "Error\n at Object.generateErrorFromResponse (/home/steve/.nvm/versions/node/v22.16.0/lib/node_modules/cht-conf/node_modules/pouchdb-errors/lib/index.js:104:18)\n at /home/steve/.nvm/versions/node/v22.16.0/lib/node_modules/cht-conf/node_modules/pouchdb-adapter-http/lib/index.js:254:33\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)",
"docId": "form:infant_child"
}
ERROR undefined
I then removed one video (3.6MB), reducing the total size to 19.1MB, but still received the same error.
After removing a second video (3.9MB), bringing the total size down to 15.2MB, the upload succeeded. This suggests the upload limit might actually be around 16MB rather than 32MB.
Is there a recommended solution to allow uploads of up to 32MB as expected?
I’m using CHT version 4.20.0 on the testing instance and version 4.5.2 on my local instance, and I encountered the same issue on both.
We are currently working on a workaround that will allow form attachments higher than 32MB.
The 32MB is the limit of the JSON payload. Was this the only attachment for this form?
No, there are other attachments (audio and images) totaling approximately 6MB. Initially, I attempted to upload the form with all attachments — videos (22.7MB), plus audio and images (6MB) — making a total of around 28.7MB, which is below the 32MB limit. However, this resulted in a 413 Request Entity Too Large error.
After removing all the audio and image files and keeping only the videos (22.7MB), the upload was successful.
To further investigate, I tested different total attachment sizes and observed the following:
23.9 MB – Worked
24.2 MB – Worked
24.45 MB – Worked
24.49 MB – Failed
This suggests the actual upload limit is somewhere just below 24.5MB, even though the raw file size is under 32MB.
Does this confirm that the 32MB limit applies to the final encoded JSON payload (after Base64 encoding), rather than the raw size of the attachments?