@clawchatsai/connector 0.0.38 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server.js +24 -7
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -1466,15 +1466,32 @@ function handleWorkspaceFileRead(req, res, query) {
|
|
|
1466
1466
|
return sendError(res, 404, 'File not found');
|
|
1467
1467
|
}
|
|
1468
1468
|
|
|
1469
|
-
// Limit file size to 1MB
|
|
1470
1469
|
const stat = fs.statSync(resolved);
|
|
1471
|
-
|
|
1472
|
-
|
|
1470
|
+
const ext = path.extname(resolved).toLowerCase().slice(1);
|
|
1471
|
+
|
|
1472
|
+
// MIME type map — binary types get served as binary, rest as text
|
|
1473
|
+
const mimeMap = {
|
|
1474
|
+
png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg',
|
|
1475
|
+
gif: 'image/gif', webp: 'image/webp', svg: 'image/svg+xml',
|
|
1476
|
+
bmp: 'image/bmp', ico: 'image/x-icon',
|
|
1477
|
+
pdf: 'application/pdf',
|
|
1478
|
+
mp3: 'audio/mpeg', mp4: 'video/mp4', wav: 'audio/wav',
|
|
1479
|
+
ogg: 'audio/ogg', webm: 'video/webm',
|
|
1480
|
+
};
|
|
1481
|
+
const mime = mimeMap[ext];
|
|
1482
|
+
const isBinary = !!mime;
|
|
1483
|
+
|
|
1484
|
+
if (isBinary) {
|
|
1485
|
+
if (stat.size > 20 * 1024 * 1024) return sendError(res, 413, 'File too large (max 20MB)');
|
|
1486
|
+
const content = fs.readFileSync(resolved);
|
|
1487
|
+
res.writeHead(200, { 'Content-Type': mime, 'Cache-Control': 'private, max-age=60' });
|
|
1488
|
+
res.end(content);
|
|
1489
|
+
} else {
|
|
1490
|
+
if (stat.size > 1024 * 1024) return sendError(res, 413, 'File too large (max 1MB)');
|
|
1491
|
+
const content = fs.readFileSync(resolved, 'utf8');
|
|
1492
|
+
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
1493
|
+
res.end(content);
|
|
1473
1494
|
}
|
|
1474
|
-
|
|
1475
|
-
const content = fs.readFileSync(resolved, 'utf8');
|
|
1476
|
-
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
1477
|
-
res.end(content);
|
|
1478
1495
|
}
|
|
1479
1496
|
|
|
1480
1497
|
async function handleWorkspaceFileWrite(req, res, query) {
|