我有一个nestjs项目,在网站的根目录有一个上传文件夹,那里有不同扩展名的文件.我应该如何处理它们?
==同步,由Elderman更正==@elder_man ==同步,由Elderman更正==@elder_man
当我这样做时,我得到一个错误:
{ "statusCode": 404, "message": "ENOENT: no such file or directory, stat 'G:\myproject\uploads\index.html'" }个
在App.Module中,我按照Nest文档中的方式执行了所有操作:
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
@Module({
imports: [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '../../../', 'uploads'),
}),
UsersModule
电源
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();