Skip to content

Add individual attachment upload for forms with large attachments #690

@dianabarsan

Description

@dianabarsan

Is your feature request related to a problem? Please describe.
The CHT-Api has a hard limit of 32MB allowance per received JSON request bodies: https://github.com/medic/cht-core/blob/5c1f9ba4a149041dd2a16e58420546731cd27b25/api/src/routing.js#L91

This means that cht-conf form upload requests: https://github.com/medic/cht-conf/blob/main/src/lib/insert-or-replace.js will also be subjected to this limitation. Which blocks uploading any form that has a total size of attachments larger than 32MB.

Describe the solution you'd like
Add a fallback in the insert-or-replace function to check the response code from API. If the response code is that the request is too large, the code should attempt to upload the doc body and each individual attachment separately. When uploading attachments, the attachment real mime type should be used as content-type in order to overcome the limitation in API.

Describe alternatives you've considered
None.

Additional context

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

🔍 In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions