Skip to content

Commit

Permalink
fix: mkdir temp
Browse files Browse the repository at this point in the history
  • Loading branch information
pociej committed Apr 25, 2024
1 parent 2af58ff commit 323b0df
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions backend/src/services/file/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { pipeline } from "node:stream";
import fs from "node:fs";
import { fileURLToPath } from "url";
import { v4 as uuidv4 } from "uuid";
import { mkdir } from "node:fs/promises";

const DIR_NAME = fileURLToPath(new URL("../../../../temp", import.meta.url));
export const fileService = fastifyPlugin(
Expand All @@ -24,6 +25,12 @@ export const fileService = fastifyPlugin(
reply.code(400).send({ message: "No file uploaded" });
return;
}

try {
await mkdir(DIR_NAME);
} catch (e) {
console.log("Error creating directory", e);
}
//accoumulate the file in memory
await util.promisify(pipeline)(
data.file,
Expand Down

0 comments on commit 323b0df

Please sign in to comment.