Adds import from URL
This commit is contained in:
21
web/src/routes/api/v1/trail/download/+server.ts
Normal file
21
web/src/routes/api/v1/trail/download/+server.ts
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user