--- title: File Storage description: Store, retrieve, list, and delete named binary or text files in MockServer's in-memory file store to use as response bodies, test fixtures, or certificate payloads. shortTitle: File Storage layout: page pageOrder: 9.7 section: 'Mock Server' subsection: true sitemap: priority: 0.7 changefreq: 'monthly' lastmod: 2026-06-01T08:00:00+00:00 ---
MockServer provides an in-memory file store accessible through four control-plane endpoints. You can upload any named file — text, JSON, binary, certificates — and then reference it by name in response templates or retrieve it directly. All stored files are cleared when MockServer is reset.
Typical use cases include uploading binary fixtures too large to embed in expectations, providing certificate files to response templates, and sharing test assets across multiple test classes without touching the filesystem.
Send a PUT request to /mockserver/files/store. The request body must contain name and content fields. Set base64 to true when uploading binary content.
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | yes | Unique name for the file. Storing a file with an existing name overwrites it. |
| content | string | yes | File content as a UTF-8 string, or as a Base64-encoded string when base64 is true. |
| base64 | boolean | no | When true, the content value is decoded from Base64 before storage. Defaults to false. |
PUT /mockserver/files/store HTTP/1.1
Content-Type: application/json
{
"name": "response-body.json",
"content": "{\"status\":\"ok\"}"
}
Response (201 Created):
{"name":"response-body.json","size":15}
PUT /mockserver/files/store HTTP/1.1
Content-Type: application/json
{
"name": "logo.png",
"content": "iVBORw0KGgo...",
"base64": true
}
Send a PUT request to /mockserver/files/retrieve with the file name. The response body is the raw file content (bytes), not a JSON wrapper.
PUT /mockserver/files/retrieve HTTP/1.1
Content-Type: application/json
{"name": "response-body.json"}
Response (200 OK) — raw file bytes:
{"status":"ok"}
Returns 404 Not Found if no file with that name exists.
Send a PUT request to /mockserver/files/list with an empty body. The response is a JSON array of file names.
PUT /mockserver/files/list HTTP/1.1
Response (200 OK):
["response-body.json","logo.png"]
Send a PUT request to /mockserver/files/delete with the file name. Returns 200 OK on success or 404 Not Found if the file does not exist.
PUT /mockserver/files/delete HTTP/1.1
Content-Type: application/json
{"name": "response-body.json"}
# Store a JSON fixture
curl -s -X PUT http://localhost:1080/mockserver/files/store \
-H 'Content-Type: application/json' \
-d '{"name":"user.json","content":"{\"id\":1,\"name\":\"Alice\"}"}'
# List stored files
curl -s -X PUT http://localhost:1080/mockserver/files/list
# Retrieve the file
curl -s -X PUT http://localhost:1080/mockserver/files/retrieve \
-H 'Content-Type: application/json' \
-d '{"name":"user.json"}'
# Delete the file
curl -s -X PUT http://localhost:1080/mockserver/files/delete \
-H 'Content-Type: application/json' \
-d '{"name":"user.json"}'