简体   繁体   English

从网络服务器导入文件到mongoDB数据库

[英]import a file from webserver to mongoDB database

我们有一个代码可以将图像文件上传到Web服务器,我们将javascript用于客户端,将node js用于服务器端,给我们的问题是,我们已将图像从Web服务器定向到mongo DB数据库并上传了mongo DB中的文件,数据库为每个上传的文件返回一个唯一ID,我们需要获取该唯一ID。

You should NOT save image into mongo db. 应该保存图像到蒙戈分贝。 you just need to store a link there assigned to whatever entity collection/document/etc you feel it necessary. 您只需要在其中存储一个分配给您认为必要的实体集合/文档/等的链接。

node js has FS api . 节点js具有FS api So use this to store image on disk. 因此,使用它在磁盘上存储映像。 and do a link a permalink to it. 并做一个永久链接。

hope that make sense. 希望有道理。

mondo db driver information here mondo db驱动程序信息在这里

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

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