TECHNOLOGY

Multipart uploads: a client filename is not a server storage path

In this article
THE QUICK TAKE

The upload filename is metadata supplied by a caller; the application decides its storage identity and destination.

Multipart has several independent names

A multipart form part can carry a field name and a filename. The field name associates the part with an API input, while the filename describes the caller’s file. Neither automatically establishes the server’s artifact identifier or destination directory.

For a dataset or model upload, a proposed API preserves an original display name separately from its generated storage identity. This avoids making an externally supplied name responsible for uniqueness, tenant separation or the location at which an executable process later opens the artifact.

The specification rejects blind path use

The multipart form-data specification tells receivers not to use a supplied filename blindly and not to use included directory path information. A validly parsed multipart request therefore still needs application-level handling of the metadata.

Decide what names may be displayed and how they are normalized for that purpose. Storage should follow the application’s defined artifact policy. Removing one path separator is not a complete definition of safe behavior across different filesystem conventions or later consumers.

Framework attributes expose metadata, not acceptance

FastAPI documents UploadFile attributes including filename and content_type, as well as a spooled file interface. These attributes make the received upload accessible; they do not establish that the content matches a claimed model format or that its name is suitable for a destination path.

A proposed processing pipeline separates receipt, content inspection and artifact acceptance. An upload can be received successfully while its declared type or downstream format remains unsupported. Preserve that distinction in the application’s state and error contract.

Boundaries belong to the multipart encoder

MDN’s FormData guidance warns against manually setting Content-Type when a browser must supply its multipart boundary. The body and header must describe the same framing. A JSON-style habit of forcing one fixed header can prevent an otherwise valid file upload from being parsed.

This is a transport-format issue, separate from the filename policy. Check both layers independently rather than diagnosing every missing file as a storage permission problem or every strange filename as a malformed multipart body.

Repeated fields and revisions need explicit policy

The specification describes multiple files for one field as separate parts sharing the field name. A consumer that assumes unique names can lose items or choose an unintended last value. Define whether the endpoint accepts one file, a list or a structured manifest.

A proposed review includes repeated fields, absent filenames, non-ASCII display names and client names containing directory information. The aim is a clear artifact interface in which transport parsing does not silently grant caller-controlled storage semantics.

Primary references

Multipart form-data specification.

FastAPI uploaded-file interface.

Browser FormData guidance.

Related explanations: Model artifact storage; Transport and body limits.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles