MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / sendFileContent

Function sendFileContent

src/lib/run.js:497–512  ·  view source on GitHub ↗

* Sends file content * @param {string} url * @param {string} id * @param {string} mime * @param {(txt: string) => string} processText * @returns

(url, id, mime, processText)

Source from the content-addressed store, hash-verified

495 * @returns
496 */
497 async function sendFileContent(url, id, mime, processText) {
498 const fs = fsOperation(url);
499
500 if (!(await fs.exists())) {
501 error(id);
502 return;
503 }
504
505 let text = await fs.readFile(appSettings.value.defaultFileEncoding);
506 text = processText ? processText(text) : text;
507 if (mime === MIMETYPE_HTML) {
508 sendHTML(text, id);
509 } else {
510 sendText(text, id, mime);
511 }
512 }
513
514 /**
515 * Sends text

Callers 2

handleRequestFunction · 0.85
sendByExtFunction · 0.85

Calls 6

fsOperationFunction · 0.85
sendHTMLFunction · 0.85
sendTextFunction · 0.85
errorFunction · 0.70
existsMethod · 0.65
readFileMethod · 0.45

Tested by

no test coverage detected