简体   繁体   English

存储 JSON 文件以在 React 应用程序中使用的最佳方式是什么?

[英]What would be the best way to store JSON files for use within a React application?

I have a python script that fetches data twice a day from a server of mine.我有一个 python 脚本,它每天从我的服务器获取数据两次。 The script returns around 40 JSON files containing various data.该脚本返回大约 40 个包含各种数据的 JSON 文件。 The files aren't particularly big and the combined size of all the files is around 250KB.这些文件不是特别大,所有文件的总大小约为 250KB。

Alongside my script I am developing a dashboard in React that renders the data from each file into a table, allowing me a visual representation of the data.除了我的脚本之外,我还在 React 中开发了一个仪表板,它将每个文件中的数据呈现到一个表中,让我可以直观地表示数据。

I have been looking at what would be the best way to store these files, something that allows me to upload and fetch them twice a day.我一直在寻找存储这些文件的最佳方式,这种方式可以让我每天上传和获取它们两次。

Someone mentioned to me about using MongoDB to store the files, but after some research I feel like Mongo is better at storing the contents of the file rather than the file itself.有人向我提到使用 MongoDB 存储文件,但经过一些研究,我觉得 Mongo 更擅长存储文件的内容而不是文件本身。 I tried to develop a solution but I couldn't figure out how it could be done when each object is stored as a document with no clear way (to me) which document came from which file.我试图开发一个解决方案,但我无法弄清楚当每个对象都存储为一个文档而没有明确的方式(对我而言)哪个文档来自哪个文件时如何完成。

Other options I have considered are:我考虑过的其他选择是:

  • Storing the files on the server that is hosting my React project and rendering them locally as I am doing now during development将文件存储在托管我的 React 项目的服务器上,并像我现在在开发期间所做的那样在本地呈现它们
  • Storing the files using a provider such as AWS/Firebase使用 AWS/Firebase 等提供商存储文件
  • Storing them in a different database (I see SQL now support the storing of JSON files)将它们存储在不同的数据库中(我看到 SQL 现在支持存储 JSON 文件)

Are there any other solutions that you think would work best for this scenario?您认为是否有任何其他解决方案最适合这种情况? If so, why?如果是这样,为什么?

Hello ,你好
Check about use of FTP server.检查 FTP 服务器的使用情况。
We have clients that send us data every 10 min via FTP that is inside XML files, then I have NodeJS back-end which read these files.我们有客户端每 10 分钟通过 XML 文件中的 FTP 向我们发送数据,然后我有读取这些文件的 NodeJS 后端。
You can use it for your scenario with JSON files.您可以将它用于带有 JSON 文件的场景。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM