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

Function uploadToTempSh

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

Source from the content-addressed store, hash-verified

839}
840
841async function uploadToTempSh(fileBlob: Blob, filename: string): Promise<string> {
842 if (Native) {
843 const result = await Native.uploadToTempSh(await fileBlob.arrayBuffer(), filename);
844 if (!result.success || !result.url) throw new Error(result.error || "No URL returned from upload");
845 return result.url;
846 }
847
848 const formData = new FormData();
849 formData.append("file", fileBlob, filename);
850
851 const uploadUrl = "https://temp.sh/upload";
852 const response = await uploadRequestWithTimeout(uploadUrl, {
853 method: "POST",
854 body: formData
855 });
856
857 if (!response.ok) {
858 throw new Error(`Upload failed: ${response.status} ${await response.text()}`);
859 }
860
861 const text = (await response.text()).trim();
862 if (!text) throw new Error("No URL returned from upload");
863 return text;
864}
865
866function makeRandomHex(length = 12): string {
867 const bytes = new Uint8Array(length);

Callers 1

uploadToServiceFunction · 0.70

Calls 2

uploadRequestWithTimeoutFunction · 0.85
textMethod · 0.80

Tested by

no test coverage detected