19 lines
710 B
TypeScript
19 lines
710 B
TypeScript
import { error } from '@sveltejs/kit';
|
|
import type { RequestHandler } from './$types';
|
|
import { getSharedMedia, SHARE_SESSION_COOKIE } from '#lib/server/shares.js';
|
|
|
|
export const GET: RequestHandler = async ({ params, cookies }) => {
|
|
const media = await getSharedMedia(params.token, cookies.get(SHARE_SESSION_COOKIE), params.id);
|
|
if (!media) error(404, 'Bild nicht gefunden');
|
|
return new Response(media.data, {
|
|
headers: {
|
|
'Content-Type': media.mimeType,
|
|
'Content-Length': String(media.byteSize),
|
|
'Cache-Control': 'private, no-store',
|
|
'Content-Security-Policy': "default-src 'none'; sandbox",
|
|
'Cross-Origin-Resource-Policy': 'same-origin',
|
|
'X-Content-Type-Options': 'nosniff'
|
|
}
|
|
});
|
|
};
|