gridfs

MongoDB as static files provider?

夙愿已清 提交于 2019-12-03 03:14:36
It's MongoDB a good candidate to serve static files (files, video) as cdn. I searching a solid way to store big amounts of data (>+To) remplacing S3 and managing cache features. Experiences. Thanks. Andrew Orsich I suppose that the answer to this question is no , because when you are using a CDN to store static files you make your server free from static data requests. But when you are choosing between a file system and mongodb Ii suppose that mongodb will be faster, beacause if there is enough ram on the server, mongo will load all data to the memory. Also I've found some links that can help

Store file in Mongo's GridFS with ExpressJS after upload

五迷三道 提交于 2019-12-03 02:29:29
问题 I have started building a REST api using expressJS. I am new to node so please bear with me. I want to be able to let users upload a file directly to Mongo's GridFS using a post to the /upload route. From what I understand in expressJS documentation the req.files.image object is available in the route after uploading, which also includes a path and filename attribute. But how can I exactly read the image data and store it into GridFS? I have looked into gridfs-stream but I can't tie ends

passing mongoose as an argument to a function

天涯浪子 提交于 2019-12-02 17:32:14
问题 I'm developing a node module. I need to pass the mongoose to my module to get three things ( mongoose.connection , mongoose.connection.db , mongoose.mongo ) out of it. index.js (myModule - the module I developed) function myModule(mongoose) { var db = mongoose.connection; var gfs = gridfsLockingStream(mongoose.connection.db, mongoose.mongo); this.someFunction = function() {//some code here} } module.exports = myModule; db.js (A user must use myModule like this) var mongoose = require(

Store file in Mongo's GridFS with ExpressJS after upload

坚强是说给别人听的谎言 提交于 2019-12-02 17:23:16
I have started building a REST api using expressJS. I am new to node so please bear with me. I want to be able to let users upload a file directly to Mongo's GridFS using a post to the /upload route. From what I understand in expressJS documentation the req.files.image object is available in the route after uploading, which also includes a path and filename attribute. But how can I exactly read the image data and store it into GridFS? I have looked into gridfs-stream but I can't tie ends together. Do I first need to read the file and then use that data for the writestream pipe? Or can I just

passing mongoose as an argument to a function

送分小仙女□ 提交于 2019-12-02 12:40:53
I'm developing a node module. I need to pass the mongoose to my module to get three things ( mongoose.connection , mongoose.connection.db , mongoose.mongo ) out of it. index.js (myModule - the module I developed) function myModule(mongoose) { var db = mongoose.connection; var gfs = gridfsLockingStream(mongoose.connection.db, mongoose.mongo); this.someFunction = function() {//some code here} } module.exports = myModule; db.js (A user must use myModule like this) var mongoose = require('mongoose'); var myModule = require('myModule'); var dbUrl = 'mongodb://localhost:27017/gfsTestDB'; mongoose

Retrieve stored image from mongodb using python

大城市里の小女人 提交于 2019-12-02 10:06:43
问题 from pymongo import MongoClient from bson.objectid import ObjectId import numpy as np import gridfs import os,os.path i=0 try: for file in os.listdir("/Users/sarthakgupta/Desktop/sae/Images"): if (file.endswith(".png") | file.endswith(".jpg")): filename = "/Users/sarthakgupta/Desktop/sae/Images/"+file datafile = open(filename,"rb") thedata = datafile.read() datafile.close() c = MongoClient() i=i+1 db = c.trial5 fs = gridfs.GridFS(db) t = "class"+str(i) stored = fs.put(thedata,filename=q)

GridFS : How to display the result of readstream.pipe(res) in an <img/> tag?

独自空忆成欢 提交于 2019-12-02 07:53:13
I am using MangoDB along with GridFS to store images. I've got this route to retrieve an image from the DB : app.get("/images/profile/:uId", function (req, res) { let uId = req.params.uId; console.log(uId) gfs.files.findOne( { "metadata.owner": uId, "metadata.type": 'profile' } , function (err, file) { if (err || !file) { return res.status(404).send({ error: 'Image not found' }); } var readstream = gfs.createReadStream({ filename: file.filename }); readstream.on("error", function (err) { res.send("Image not found"); }); readstream.pipe(res); }); }); This returns something like that : �PNG IHDR

Using mongofiles with GridFS in a meteor app

佐手、 提交于 2019-12-02 05:50:16
问题 I am starting to use GridFS within a Meteor app. I have set up the file collection "assetFiles" with a GridFS storage adapter like this : AssetCollection = new Mongo.Collection( "assets" ); AssetFileStore = new FS.Store.GridFS( "assetFiles" ); AssetFilesCollection = new FS.Collection( "assetFiles", { stores: [AssetFileStore] }); AssetFilesCollection.allow({ insert: function(){ return true; }, update: function(){ return true; }, remove: function(){ return true; }, download: function(){ return

Using mongofiles with GridFS in a meteor app

◇◆丶佛笑我妖孽 提交于 2019-12-02 01:45:24
I am starting to use GridFS within a Meteor app. I have set up the file collection "assetFiles" with a GridFS storage adapter like this : AssetCollection = new Mongo.Collection( "assets" ); AssetFileStore = new FS.Store.GridFS( "assetFiles" ); AssetFilesCollection = new FS.Collection( "assetFiles", { stores: [AssetFileStore] }); AssetFilesCollection.allow({ insert: function(){ return true; }, update: function(){ return true; }, remove: function(){ return true; }, download: function(){ return true; } }); I have inserted some files in it and using meteor mongo client checked they actually exist

MongoDB - Maximum file size using GridFS

左心房为你撑大大i 提交于 2019-12-01 20:33:52
问题 I am wondering what is the maximum file size if someone wants to store a file using the GridFS? I can't find any information so any help would be appreciated. 回答1: Infinity basically, or a more exact number would be how much your working set allows. The GridFS standard implemented within drivers will split files up into smaller chunks and store them in a fs.chunks collection irrespective of how big the file is. 来源: https://stackoverflow.com/questions/16604875/mongodb-maximum-file-size-using