CodamAIDocs
Topicdone

Size limits

Which size limits apply to uploads and downloads, what happens when one is exceeded, and where to configure them.

Variants
upload: 25 MB per file, 500 MB per request, 500 partssame limits for multipart and Base64413 with the limit in the messageKeysetting via standard propertiesproxy and ingress in frontdownload: whole file in memoryhard limit 2 GiBno quota per tenant

What this is about

Files can be large, and large files cost memory, network and time. Size matters in three places: when uploading, when downloading and in the file storage.

The limits at a glance

WhereLimitConfigurable?
one file (multipart or Base64)25 MByes, spring.servlet.multipart.max-file-size
all files of a request500 MByes, spring.servlet.multipart.max-request-size
parts of a multipart request500yes, server.tomcat.max-part-count
downloadwhole file in memory, per running download–
file size overall2 GiB, because fileSize is an integer up to 2³¹−1no
file storage per tenantno quota–

The values are chosen so that an operation can send all of its files in one request, for example an inspection with 100 photos of 5 MB each. A request is stored completely or not at all. Files uploaded one by one could be left half-distributed after an interruption.

For Base64, the size of the file counts, not that of the text. CDMS works it out from the length of the text before decoding anything. All Base64 files of a request together may be at most as large as the request limit.

What happens with a file that is too large

An upload above the limit
What is too large?WayAnswer
nothingallis stored
one filemultipart or Base64413 file-too-large|<bytes>
all files togethermultipart or Base64413 request-too-large|<bytes>
the number of partsmultipart413 too-many-parts|<count>

The number after the | is the limit: in bytes for files and requests, as a count for parts. So file-too-large|26214400 means “at most 25 MB per file”. In each of these cases nothing is stored. Repeating the request unchanged fails the same way.

If the server cannot name a limit, the answer is 413 upload-too-large.

Configuring the limits

CDMS brings the defaults itself. If your application sets one of the values, its own applies. In the application.yaml:

Uploads up to 50 MB per file, 1 GB per request
Request
spring:
  servlet:
    multipart:
      max-file-size: 50MB
      max-request-size: 1GB
server:
  tomcat:
    max-part-count: 1000
Or as environment variables
SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE=50MB
SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE=1GB
SERVER_TOMCAT_MAX_PART_COUNT=1000

The request limit has to be at least as large as the file limit, otherwise it takes effect first. -1 means unlimited.

Why downloads are the real limit

When downloading, CDMS reads the whole file into memory and then sends it. The need is therefore roughly:

concurrent downloads × file size

Ten concurrent downloads of a 200 MB file need about 2 GB of memory, just for the files. That is why CDMS is designed for files up to about 25 MB: documents, images, scans. For videos or large archives, a separate store that CDMS only points to is better suited.

Pitfalls

What comes next

Sources in the code and the knowledge base
  • CDMS/cdms-rest-api – UploadLimitDefaults (defaults), UploadLimits, ClientErrorTranslator (413 keys), AbstractRestApi.addFilesFromBase64 (Base64 limits), ObjectMapperConfig (string length), UploadLimitContainerTest, UploadLimitDefaultsTest
  • CDMS/cdms-localfs-storage – LocalFSFileController.getFile (readAllBytes), docs/adr/ADR-009, ADR-019 (measured ~5 MB, documented maximum 25 MB), docs/05-configuration.md (no quota)
  • CDMS/cdms-commons – FileInterface (fileSize Integer), FileUploadException (413)
  • documentation/10-cdms-grundlagen/04-konfiguration.md (Uploads), 05-api-guide/09-dateien.md
Search