MCPcopy Index your code
hub / github.com/github/awesome-copilot / downloadFile

Function downloadFile

website/src/scripts/utils.ts:215–231  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

213 * Download a file from its path
214 */
215export async function downloadFile(filePath: string): Promise<boolean> {
216 try {
217 const response = await fetch(`${REPO_BASE_URL}/${filePath}`);
218 if (!response.ok) throw new Error("Failed to fetch file");
219
220 const content = await response.text();
221 const filename = filePath.split("/").pop() || "file.md";
222
223 const blob = new Blob([content], { type: "text/markdown" });
224 triggerBlobDownload(blob, filename);
225
226 return true;
227 } catch (error) {
228 console.error("Download failed:", error);
229 return false;
230 }
231}
232
233/**
234 * Share/copy link to clipboard (deep link to current page with file hash)

Callers 2

setupModalFunction · 0.90
setupActionHandlersFunction · 0.85

Calls 1

triggerBlobDownloadFunction · 0.85

Tested by

no test coverage detected