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

Function uploadToBuzzheavier

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

Source from the content-addressed store, hash-verified

807}
808
809async function uploadToBuzzheavier(fileBlob: Blob, filename: string): Promise<string> {
810 if (Native) {
811 const result = await Native.uploadToBuzzheavier(await fileBlob.arrayBuffer(), filename);
812 if (!result.success || !result.url) throw new Error(result.error || "No URL returned from upload");
813 return result.url;
814 }
815
816 const uploadUrl = `https://w.buzzheavier.com/${encodeURIComponent(filename)}`;
817 const response = await uploadRequestWithTimeout(uploadUrl, {
818 method: "PUT",
819 body: fileBlob
820 });
821
822 const text = await response.text();
823 if (!response.ok) {
824 throw new Error(`Upload failed: ${response.status} ${text}`);
825 }
826
827 try {
828 const data = JSON.parse(text) as { code?: number; data?: { id?: string; }; };
829 const id = data.data?.id;
830 if (data.code === 201 && id) {
831 return `https://buzzheavier.com/${id}`;
832 }
833 } catch {
834 }
835
836 const fallback = text.trim();
837 if (!fallback) throw new Error("No URL returned from upload");
838 return fallback;
839}
840
841async function uploadToTempSh(fileBlob: Blob, filename: string): Promise<string> {
842 if (Native) {

Callers 1

uploadToServiceFunction · 0.70

Calls 2

uploadRequestWithTimeoutFunction · 0.85
textMethod · 0.80

Tested by

no test coverage detected