栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

MongoDB GridFS使用Node.JS保存文件时出现问题

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

MongoDB GridFS使用Node.JS保存文件时出现问题

有两种解决方案。您可以使用writeBuffer,writeFile或新的简单网格类。在下面的示例中,针对使用缓冲区实例的事实进行了调整。

// You can use an object id as well as filename nowvar gs = new mongodb.GridStore(this.db, filename, "w", {  "chunk_size": 1024*4,  metadata: {    hashpath:gridfs_name,    hash:hash,    name: name  }});gs.open(function(err,store) {  // Write data and automatically close on finished write  gs.writeBuffer(data, true, function(err,chunk) {    // Each file has an md5 in the file structure    cb(err,hash,chunk);  });});

通常,最好的起点是覆盖gridfs类的广泛使用情况的测试。看着。

https://github.com/christkv/node-mongodb-
native/tree/master/test/gridstore



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/484843.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号