Skip to content

Commit

Permalink
use async
Browse files Browse the repository at this point in the history
  • Loading branch information
nicnocquee committed Nov 21, 2023
1 parent 5d0224a commit 1679eb5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/api/download/[file_name]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ export const GET = async (
const filePath = path.join(process.cwd(), `./files/${decodedFileName}`);

try {
fs.accessSync(filePath, fs.constants.R_OK);
await fs.promises.access(filePath, fs.constants.R_OK);
} catch (err: any) {
if (err.code === "ENOENT") {
return new Response("File not found", { status: 404 });
} else {
console.error(err);
// Handle other possible errors (e.g., permission issues)
return new Response("Error accessing file", { status: 500 });
}
Expand Down

0 comments on commit 1679eb5

Please sign in to comment.