feat: use environment variable for uploads directory path
All checks were successful
Build Docker Image / build (push) Successful in 1m26s
All checks were successful
Build Docker Image / build (push) Successful in 1m26s
This commit is contained in:
@@ -6,6 +6,7 @@ import type { PageServerLoad, Actions } from './$types';
|
|||||||
import { writeFile } from 'fs/promises';
|
import { writeFile } from 'fs/promises';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { existsSync, mkdirSync } from 'fs';
|
import { existsSync, mkdirSync } from 'fs';
|
||||||
|
import { env } from '$env/dynamic/private';
|
||||||
|
|
||||||
export const load: PageServerLoad = async () => {
|
export const load: PageServerLoad = async () => {
|
||||||
const [charactersData, devilFruits, arcs, overrides] = await Promise.all([
|
const [charactersData, devilFruits, arcs, overrides] = await Promise.all([
|
||||||
@@ -109,7 +110,7 @@ export const actions: Actions = {
|
|||||||
const hasUploadedPicture = !!pictureFile && pictureFile.size > 0;
|
const hasUploadedPicture = !!pictureFile && pictureFile.size > 0;
|
||||||
if (hasUploadedPicture) {
|
if (hasUploadedPicture) {
|
||||||
try {
|
try {
|
||||||
const uploadsDir = join(process.cwd(), 'uploads');
|
const uploadsDir = join(process.cwd(), env.UPLOAD_FOLDER || 'uploads');
|
||||||
if (!existsSync(uploadsDir)) {
|
if (!existsSync(uploadsDir)) {
|
||||||
mkdirSync(uploadsDir, { recursive: true });
|
mkdirSync(uploadsDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { readFile } from 'fs/promises';
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
import { env } from '$env/dynamic/private';
|
||||||
|
|
||||||
export const GET: RequestHandler = async ({ params }) => {
|
export const GET: RequestHandler = async ({ params }) => {
|
||||||
const filename = params.filename as string;
|
const filename = params.filename as string;
|
||||||
@@ -11,7 +12,7 @@ export const GET: RequestHandler = async ({ params }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const uploadsDir = join(process.cwd(), 'uploads');
|
const uploadsDir = join(process.cwd(), env.UPLOAD_FOLDER || 'uploads');
|
||||||
const filepath = join(uploadsDir, filename);
|
const filepath = join(uploadsDir, filename);
|
||||||
|
|
||||||
if (!existsSync(filepath)) {
|
if (!existsSync(filepath)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user