【问题标题】:How do i handle file uploads in NestJs Microservice我如何处理 NestJs 微服务中的文件上传
【发布时间】:2020-11-14 18:35:31
【问题描述】:

我是否在 Nestjs 微服务中处理文件上传?

由于微服务不使用 http req @FileInterceptor 或 Multer 将无法工作。 即使有解决方法我也不知道。

请帮忙

【问题讨论】:

  • 你能写代码吗?还是您面临的错误?

标签: javascript node.js microservices nestjs multer


【解决方案1】:

有一个概念叫Hybrid Application 在nest.js 中。这使您能够侦听 HTTP 请求,并利用连接的微服务。

类似这样的:

// Create your regular nest application.
const app = await NestFactory.create(ApplicationModule);

// Then combine it with your microservice
const ms = app.connectMicroservice({
  transport: Transport.TCP,
  options: { host: '0.0.0.0', port: 6000 }
});

await app.startAllMicroservicesAsync();
await app.listen(3000);

【讨论】:

  • 是的,我用过这个,但我想知道我们是否可以通过 TCP 以消息模式发送文件
猜你喜欢
  • 2020-01-14
  • 2020-10-20
  • 1970-01-01
  • 2022-11-30
  • 2022-06-15
  • 1970-01-01
  • 1970-01-01
  • 2011-11-09
  • 2021-01-12
相关资源
最近更新 更多