| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/foyer-web/current/node_modules/@scalar/api-reference/dist/helpers/ |
Upload File : |
import { redirectToProxy } from "@scalar/helpers/url/redirect-to-proxy";
//#region src/helpers/upload-temp-document.ts
/** Type guard for the response body */
function isResponseBody(data) {
return !!data && typeof data === "object" && "url" in data && typeof data.url === "string";
}
/** Upload a document and return a temporary URL */
async function uploadTempDocument(document, urls) {
const body = JSON.stringify({ document });
const uploadUrl = `${urls.apiBaseUrl}/core/share/upload/apis`;
const response = await fetch(redirectToProxy(urls.proxyUrl, uploadUrl), {
method: "POST",
headers: { "Content-Type": "application/json" },
body
});
if (!response.ok) throw new Error(` Failed to generate temporary link, server responded with ${response.status}`);
const data = await response.json();
if (!isResponseBody(data)) throw new Error("Failed to generate temporary link, invalid response from server");
return data.url;
}
//#endregion
export { uploadTempDocument };
//# sourceMappingURL=upload-temp-document.js.map