MCPcopy Create free account
hub / github.com/ScattrdBlade/bigFileUpload / uploadToEzHost

Function uploadToEzHost

utils/upload.ts:623–667  ·  view source on GitHub ↗
(fileBlob: Blob, filename: string)

Source from the content-addressed store, hash-verified

621}
622
623async function uploadToEzHost(fileBlob: Blob, filename: string): Promise<string> {
624 const { ezHostKey } = (settings.store as { ezHostKey?: string; });
625
626 if (!ezHostKey) throw new Error("E-Z Host API key is required");
627
628 if (Native) {
629 const arrayBuffer = await fileBlob.arrayBuffer();
630 const result = await Native.uploadToEzHost(arrayBuffer, filename, ezHostKey);
631
632 if (!result.success) {
633 throw new Error(result.error || "Upload failed");
634 }
635
636 if (!result.url) {
637 throw new Error("No URL returned from upload");
638 }
639
640 return result.url;
641 }
642
643 const formData = new FormData();
644 formData.append("file", fileBlob, filename);
645
646 const headers: Record<string, string> = { key: ezHostKey };
647
648 const response = await uploadRequestWithTimeout("https://api.e-z.host/files", {
649 method: "POST",
650 headers,
651 body: formData
652 });
653
654 if (!response.ok) {
655 const text = await response.text();
656 throw new Error(`Upload failed: ${response.status} ${text}`);
657 }
658
659 const data = await response.json() as { success?: boolean; error?: string; imageUrl?: string; rawUrl?: string; };
660 if (!data || !data.success) {
661 throw new Error(data?.error || "Upload failed");
662 }
663
664 const url = data.imageUrl || data.rawUrl;
665 if (!url) throw new Error("No URL returned from upload");
666 return url;
667}
668
669async function uploadToCatbox(fileBlob: Blob, filename: string): Promise<string> {
670 const { catboxUserhash } = settings.store;

Callers 1

uploadToServiceFunction · 0.70

Calls 3

uploadRequestWithTimeoutFunction · 0.85
textMethod · 0.80
jsonMethod · 0.80

Tested by

no test coverage detected