简体   繁体   English

如何使用 node.js 应用程序从客户端获取数据作为 .csv 文件

[英]How to fetch data as .csv file from client with node.js application

i have written a game in javascript with the p5.js library.我用 p5.js 库用 javascript 编写了一个游戏。 Now i want to host the game on a server to conduct a survey on a service like amazon turk.现在我想在服务器上托管游戏,以对亚马逊土耳其人这样的服务进行调查。 Ideally the clients recieve a URL to the game and play it while in-game actions are tracked and stored in node.js or on the server and exported as a .csv file once they are done playing.理想情况下,客户端会收到游戏的 URL 并玩游戏,同时跟踪游戏中的动作并将其存储在 node.js 或服务器上,并在游戏完成后导出为 .csv 文件。 After they finish the game the csv.在他们完成游戏后,csv。 file should be sent automatically to a location that i can then access.文件应自动发送到我可以访问的位置。 I have zero experience in server hosting or similar topics.我在服务器托管或类似主题方面的经验为零。

So a couple questions arise:所以出现了几个问题:

  1. Is a hosting service like Heroku suitable for hosting the game?像 Heroku 这样的托管服务是否适合托管游戏?
  2. Do i need to use node.js to make this happen?我需要使用 node.js 来实现这一点吗?
  3. Which of those two would extract the data and store it to a csv?这两个中的哪一个会提取数据并将其存储到 csv 中? And where is the file stored?文件存储在哪里?
  4. How do i get or access the csv.我如何获取或访问 csv。 after?后?
  5. Any alternative takes to solve the problem?有什么办法可以解决这个问题吗?

Thanks alot in advance!提前非常感谢!

If I were you, I would do it like below:如果我是你,我会这样做:

Host Since your project is basically a html & JavaScript static contents, AWS S3's static hosting would be sufficient (Also, the current git hub pages is another option if you just want to host it).托管由于您的项目基本上是一个 html 和 JavaScript 静态内容,AWS S3 的静态托管就足够了(另外,如果您只想托管它,当前的 git hub 页面是另一种选择)。

Hosting on node.js environment is also available using webpack serving, but it requires additional works.使用webpack服务也可以在 node.js 环境中托管,但需要额外的工作。 (but if you require other npm packages to generate .csv file, you need webpack anyway to bundle js file and attach it to html) (但如果您需要其他 npm 包来生成 .csv 文件,则无论如何都需要 webpack 来捆绑 js 文件并将其附加到 html)

Data Storing Two ways are considerable, the first is to store it on the filesystem.数据存储两种方式相当重要,第一种是将其存储在文件系统中。 Generate .csv via JS script within your app, and save it where the app is hosted (if you go with s3, you can access it afterwards, but I'm not sure if it can write objects by script)在您的应用程序中通过JS脚本生成.csv,并将其保存在托管应用程序的位置(如果您使用s3,您可以在之后访问它,但我不确定它是否可以通过脚本编写对象)

The second is to post the data to another API endpoint.第二个是将数据发布到另一个 API 端点。 (for example building an API Gateway on AWS that triggers Lambda, which stores it on S3) (例如在 AWS 上构建一个触发 Lambda 的 API 网关,并将其存储在 S3 上)

It's merely an example and I don't know exactly what you want to achieve, but take it into considerations.这只是一个示例,我不确切知道您想要实现什么,但请考虑一下。 Good luck.祝你好运。 Cool game BTW.酷游戏顺便说一句。

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

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