507 Insufficient Storage means the server cannot store the representation needed to complete the request. Defined in WebDAV, it is returned when disk space or a quota runs out during an upload or storage operation.
This is a server-side resource limit. It happens when physical disk space is low, a per-user or per-account storage quota is exceeded, or a temporary storage area is full.
PUT /files/backup.zip HTTP/1.1
Host: dav.example.com
Content-Type: application/zip
Content-Length: 524288000
<500 MB body>HTTP/1.1 507 Insufficient Storage
Content-Type: application/xml
<D:error xmlns:D="DAV:"><D:quota-not-exceeded/></D:error>app.put('/files/:name', async (req, res) => {
const free = await getFreeBytes(storageDir);
if (Number(req.headers['content-length']) > free) {
return res.status(507).send('Insufficient Storage');
}
// stream the upload to disk...
});