Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
Web, API & dataMiddleCommonPractical

How can an API request upload a file, and can the file be sent together with other data?

Answer

An endpoint can accept a raw binary body with a specific media type or application/octet-stream. When a file must be sent together with text fields or metadata, multipart/form-data is the usual HTTP representation: each part has its own Content-Disposition and optional Content-Type, so one part can be the file and another can be text or JSON metadata. Base64 inside JSON is possible but adds size and processing overhead. Some systems instead issue a pre-signed storage URL and persist metadata separately.

Strong answer includes

  • raw binary versus multipart/form-data
  • file and metadata can coexist as multipart parts
  • base64 and pre-signed upload trade-offs

Practical example

A profile endpoint accepts displayName and avatar in one multipart request. The tester verifies the text part, filename, image Content-Type, zero-byte and oversized files, and that another user cannot later download the uploaded object.

#file-upload#multipart#api-testing#rest-api

Sources

MDN HTTP referenceMozilla · HTTP methods, messages, status codes, headers, cookies and cachingDOU — QA interview: 250+ questionsDOU · Coverage signal across Junior, Middle, Senior, AQA, web, mobile and practical topics