Skip to content

Commit

Permalink
Photo API fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Spytex committed Jul 20, 2023
1 parent b1eccce commit 0fa56bd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Binary file removed public/photos/95753307.jpg
Binary file not shown.
Binary file removed public/photos/95753348.jpg
Binary file not shown.
6 changes: 3 additions & 3 deletions src/pages/api/photo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const middlewares: Middlewares = {
}


const readFile = async (
const readFile = (
req: NextApiRequest,
saveLocally?: boolean,
): Promise<{ fields: formidable.Fields; files: formidable.Files }> => {
Expand Down Expand Up @@ -52,7 +52,7 @@ async function postPhoto(options: IMiddlewareOptions) {
} catch (error) {
await fs.mkdir(path.join(process.cwd() + "/public", "/photos"));
}
await readFile(req, true);
readFile(req, true);
res.json({ done: "ok" });
}

Expand All @@ -66,7 +66,7 @@ async function deletePhoto(options: IMiddlewareOptions) {
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const method = req.method as HttpMethod;
if (!Object.keys(middlewares).includes(method)) {
res.setHeader('Allow', ['POST', 'GET', 'DELETE']);
res.setHeader('Allow', ['POST', 'DELETE']);
res.status(405).end(`Method ${req.method} Not Allowed`);
}

Expand Down

0 comments on commit 0fa56bd

Please sign in to comment.