Adds import from URL

This commit is contained in:
Christian Beutel
2025-02-01 20:36:39 +01:00
parent 0cf17cbd86
commit 3ab591177a
17 changed files with 208 additions and 41 deletions

View File

@@ -0,0 +1,21 @@
import { handleError } from "$lib/util/api_util";
import { type RequestEvent } from "@sveltejs/kit";
export async function POST(event: RequestEvent) {
const data = await event.request.json();
try {
const response = await event.fetch(data.url);
const blob = await response.blob();
const contentType = 'determine the content type here';
return new Response(blob, {
headers: {
'Content-Type': contentType,
},
});
} catch (e) {
throw handleError(e)
}
}