Spaces:
Sleeping
Sleeping
File size: 802 Bytes
6b8f69a 314f2dc 6b8f69a 314f2dc 5d7d435 8e3dbd3 314f2dc bc0330e 6b8f69a 1a37272 314f2dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import { getPresignedUrl } from '@/lib/aws';
import { withLogging } from '../../../lib/logger';
import { nanoid } from '@/lib/utils';
/**
* @param req
* @returns
*/
export const POST = withLogging(
async (
session,
json: {
id?: string;
fileName: string;
fileType: string;
},
): Promise<Response> => {
const user = session?.user?.email ?? 'anonymous';
// if (!email) {
// return new Response('Unauthorized', {
// status: 401,
// });
// }
try {
const { fileName, fileType, id = nanoid() } = json;
const res = await getPresignedUrl(fileName, fileType, id, user);
return Response.json(res);
} catch (error) {
return new Response((error as Error).message, {
status: 400,
});
}
},
);
|