How to Test File Upload APIs with Postman (Multipart & Binary)
Learn to test file upload endpoints in Postman using multipart/form-data and binary body modes. Covers Postman scripts, large file testing, and common error codes.
Testing file upload APIs with Postman is an essential step in verifying backend file ingestion, multipart encoding, validation boundaries, and cloud storage presigned URL endpoints. This guide covers end-to-end setup for automated Postman testing.
Setting Up Multipart/Form-Data Uploads in Postman
When testing standard REST endpoints accepting multipart/form-data, Postman provides native file attachment capabilities.
Step 1: Configure the Request Body
- Set the HTTP method to POST and enter your endpoint URL (e.g.,
https://api.example.com/v1/uploads). - Navigate to the Body tab and select form-data.
- In the key column, type the field name your server expects (such as
fileorattachment). - Hover over the right edge of the key field, click the dropdown, and change the type from Text to File.
- Click Select Files and choose a sample test file.
Need a clean 10MB Word document to test your file upload API? Download our verified sample file.
Download 10MB DOCX Sample βAutomated Postman Tests for File Upload APIs
To verify response status, payload schemas, and uploaded file attributes, use Postman's Tests script tab:
pm.test("Status code is 201 Created", function () {
pm.response.to.have.status(201);
});
pm.test("Response contains valid file metadata", function () {
const json = pm.response.json();
pm.expect(json).to.have.property("fileId");
pm.expect(json).to.have.property("fileSize");
pm.expect(json.mimeType).to.eql("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
});
pm.test("Upload processing time is under 2000ms", function () {
pm.expect(pm.response.responseTime).to.be.below(2000);
});
Testing Binary Raw Uploads (Octet-Stream)
Some high-throughput APIs accept binary streams directly without multipart overhead:
- Under Body, select binary.
- Select your test binary file.
- In the Headers tab, explicitly set
Content-Typetoapplication/octet-streamor the appropriate MIME type.
Testing File Size Limits and Error Responses
Be sure to create negative test cases in your Postman collection:
- Empty file (0 bytes): Verify your server returns HTTP 400 Bad Request with a clear message.
- Oversized file (e.g. 50MB against a 20MB limit): Verify HTTP 413 Payload Too Large.
- Wrong MIME type: Ensure your backend rejects disallowed formats with HTTP 415 Unsupported Media Type.
Nguyen Dai Long
AuthorBackend Lead β’ Distributed Systems & Cloud Edge Architecture Specialist
4+ years designing high-throughput file ingestion pipelines, database architectures, and distributed edge storage on Cloudflare R2 & AWS S3. Founder of FileDummy and the NDL Ecosystem.
Was this article helpful?
Click Like to support the author and help other developers discover this guide.
Engineering Discussion & Feedback (0)
Share benchmark results, report edge cases, or ask technical questions.
No comments yet. Be the first developer to start the discussion!
Frequently Asked Questions
How do I upload a file in Postman using multipart/form-data?βΎ
In the request Body tab, select form-data, add a key with type File, then select your local file. Postman automatically sets the Content-Type: multipart/form-data header with the correct boundary β do not set it manually.
How do I upload a file as raw binary in Postman?βΎ
Select Body β binary, then choose your file. This sends the file as the raw request body without form encoding β useful for APIs expecting Content-Type: application/pdf directly in the body, or for direct S3 PUT uploads.
Why does Postman fail with large files?βΎ
Postman Desktop has no inherent size limit. Issues usually come from the API server: nginx body size limit, Express bodyParser limit, or AWS API Gateway's 10MB hard limit. Check server logs for 413 Request Entity Too Large errors.