I am working on a project using NestJS, and I have an uploads folder in the root directory of the site where files with various extensions are stored. How should I go about processing these files?
Here are some example file paths:
http://localhost:7777/uploads/audio/85/0.mp3
http://localhost:7777/uploads/movie/85/0.mp4
When attempting to access these files, I encounter the following error:
{ "statusCode": 404, "message": "ENOENT: no such file or directory, stat 'G:\myproject\uploads\index.html'" }
In my App.module file, I followed the instructions from the Nest documentation:
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
@Module({
imports: [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '../../../', 'uploads'),
}),
UsersModule
In my Main.ts file, I have the following setup:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './App/app.module';
import { ConfigService } from '@nestjs/config';
import { ValidationPipe } from '@nestjs/common';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const configService = app.get(ConfigService);
const port = configService.get('PORT');
app.enableCors();
app.useGlobalPipes(new ValidationPipe());
await app.listen(port);
}
bootstrap();