Skip to content

Commit

Permalink
Import assessment refinement - location for local storage is added
Browse files Browse the repository at this point in the history
  • Loading branch information
Dattatraya-Londhe committed Nov 25, 2023
1 parent 1764c43 commit 662cd50
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { importAssessmentTemplate } from "$routes/api/services/assessment-templa
import type { RequestEvent } from "@sveltejs/kit";
import { redirect } from 'sveltekit-flash-message/server';
import { errorMessage, successMessage } from '$lib/utils/message.utils';
import { PUBLIC_LOCAL_STORAGE } from '$env/static/public';
import { Buffer } from "buffer";
import * as fs from 'fs';

Expand All @@ -14,10 +15,11 @@ export const actions = {
const formData = await request.formData();
const uploadedFile = formData?.get('name') as File;
const fileName = uploadedFile.name;
const filePath = `./temp/${fileName}`;
const fileUploadFolder = PUBLIC_LOCAL_STORAGE;
const filePath = `${fileUploadFolder}/${fileName}`;

if (!fs.existsSync('./temp')) {
fs.mkdirSync('./temp', { recursive: true });
if (!fs.existsSync(`${fileUploadFolder}`)) {
fs.mkdirSync(`${fileUploadFolder}`, { recursive: true });
}

await writeFile(filePath, Buffer.from(await uploadedFile?.arrayBuffer()));
Expand Down

0 comments on commit 662cd50

Please sign in to comment.