fix(file-upload): re-enabled file upload for mistral & url for file upload (#408)

* re-enabled file upload for mistral & url for file upload

* consolidated env checks
This commit is contained in:
Waleed Latif
2025-05-24 20:58:49 -07:00
committed by GitHub
parent 79b761c022
commit 950e055a8d
6 changed files with 21 additions and 53 deletions

View File

@@ -1,27 +1,23 @@
import { existsSync } from 'fs'
import { mkdir } from 'fs/promises'
import path, { join } from 'path'
import { isProd } from '@/lib/environment'
import { createLogger } from '@/lib/logs/console-logger'
import { env } from '../env'
const logger = createLogger('UploadsSetup')
// Define project root - this works regardless of how the app is started
const PROJECT_ROOT = path.resolve(process.cwd())
// Define the upload directory path using project root
export const UPLOAD_DIR = join(PROJECT_ROOT, 'uploads')
export const USE_S3_STORAGE = env.NODE_ENV === 'production' || env.USE_S3
export const USE_S3_STORAGE = isProd
export const S3_CONFIG = {
bucket: env.S3_BUCKET_NAME || '',
region: env.AWS_REGION || '',
}
/**
* Ensures that the uploads directory exists (for local storage)
*/
export async function ensureUploadsDirectory() {
if (USE_S3_STORAGE) {
logger.info('Using S3 storage, skipping local uploads directory creation')