最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Nest Js - How to generate a file and send it as a request response without saving the file locally? - Stack Overflo

programmeradmin1浏览0评论

I have a task where I need to export a json to csv via an endpoint. When accessing the endpoint, the route should return the .csv file with the data. Is there a way to do this without having to save the file locally?

I have a task where I need to export a json to csv via an endpoint. When accessing the endpoint, the route should return the .csv file with the data. Is there a way to do this without having to save the file locally?

Share Improve this question asked Mar 15, 2022 at 14:43 Adam AAdam A 771 silver badge5 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

If you use a File Interceptor on a route without specifying a storage option, the file will exist purely in memory and you will not need to save it to the disk.

I should warn however that if a uploaded file is very large, you can run out of memory. It's generally a better option to save to the disk as a temp file, then delete afterwards.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论