gridfs

Gridfs and mongoose file upload

瘦欲@ 提交于 2019-12-08 13:29:25
问题 I have ran into a problem with gridfs file upload. Basically I get this bizzare error and I have yet not found solution for solving this problem. Here is my code that should deal with file upload: var path = require('path'); var router = require('express').Router(); var mongoose = require('mongoose'); var serverConfig = require('../config.js'); var multiparty = require('connect-multiparty')(); var fs = require('fs'); var GridFs = require('gridfs-stream'); var db = mongoose.connection.db; var

build an API for streaming audio/video from GridFS mongodb

人盡茶涼 提交于 2019-12-08 08:04:34
问题 I have tried the solution given in the link stream audio/video files from gridFS on the browser Still when I use my code the file gets downloaded or it plays with the default browser player. My code is as: header('Content-type: audio/mpeg;'); $stream = $file->getResource(); while (!feof($stream)) { echo fread($stream, 8192); } I actually want a solution to build an API so that I can retrieve the audio/video from mongodb GridFS and play it streaming from a phone application. Help is urgently

stream audio/video files from gridFS on the browser

强颜欢笑 提交于 2019-12-08 06:02:21
问题 I have been trying to read an audio file from mongoDB which i have stored using GridFS. I could download the file in the system and play from it but I wanted to stream those audio/video files from the DB itself and play it in the browser. Is there anyway to do that without downloading the file to the system? Any help would be good. 回答1: The PHP GridFS support has a MongoGridFSFile::getResource() function that allows you to get the stream as a resource - which doesn't load the whole file in

MongoDB - mongofiles

白昼怎懂夜的黑 提交于 2019-12-08 03:00:22
问题 C:\Programs\MongoDB\bin>mongofiles.exe list connected to: 127.0.0.1 test123.txt 6 test123.txt 22 test123.txt 44 test456.txt 53 test456.txt 53 test456.txt 53 test456.txt 53 test456.txt 53 test456.txt 15 C:\Programs\MongoDB\bin> When I do mongofiles get test456.txt I always get the last file which I put with that name in GridFS. How do I get the other/previous ones provided they all have duplicate names? According to the documentation I need to specify: "A filename which is either: the name of

MongoDB GridFS - Is it filename or fileName

柔情痞子 提交于 2019-12-08 01:33:46
问题 Please look at the following image, from http://mongoexplorer.com/: I've been trying to work through GridFS, referencing https://github.com/jamescarr/nodejs-mongodb-streaming. The files I uploaded, come back nicely and the stream that comes back via the following get function looks right. var gridfs = (function () { function gridfs() { } gridfs.get = function (id, fn) { var db, store; db = mongoose.connection.db; id = new ObjectID(id); store = new GridStore(db, id, "r", { root: "fs" });

How can I specify a GridFS bucket?

耗尽温柔 提交于 2019-12-07 14:10:34
问题 This is my express.js code to upload and download files to GridFS: var fs = require("fs"); var gridStream = require("gridfs-stream"); var mongoose = require("mongoose"); exports.init = function(app, db) { var grid = gridStream(db, mongoose.mongo); app.post("/UploadFile", function(request, response) { var file = request.files.UploadedFile; var meta = request.param("Meta"); var name = request.param("Name"); var stream = grid.createWriteStream( { filename: name, metadata: meta }); fs

MongoDB GridFS "illegal chunk format' exception

你说的曾经没有我的故事 提交于 2019-12-07 01:59:35
问题 I've been writing an app in Node.js that stores images in MongoDB's GridFS file system. I've uploaded images through the app, and the images appear to be stored correctly: $ mongofiles -v -d speaker-karaoke get howard-basement-100x115.jpg Tue Jul 17 12:14:16 creating new connection to:127.0.0.1 Tue Jul 17 12:14:16 BackgroundJob starting: ConnectBG Tue Jul 17 12:14:16 connected connection! connected to: 127.0.0.1 done write to: howard-basement-100x115.jpg This grabbed the .jpg out of MongoDB

Saving Files to MongoDB GridFS with Node.JS

放肆的年华 提交于 2019-12-06 16:02:06
How do you put the close() in the writeBuffer callback? This question relates to: Problem with MongoDB GridFS Saving Files with Node.JS A simple example is https://github.com/mongodb/node-mongodb-native/blob/master/test/gridstore/grid_store_test.js#L97 Also check the docs for changes in behavior, writeBuffer was removed so just use write. http://mongodb.github.com/node-mongodb-native/ 来源: https://stackoverflow.com/questions/10092282/saving-files-to-mongodb-gridfs-with-node-js

MongoDB - mongofiles

落爺英雄遲暮 提交于 2019-12-06 13:26:53
C:\Programs\MongoDB\bin>mongofiles.exe list connected to: 127.0.0.1 test123.txt 6 test123.txt 22 test123.txt 44 test456.txt 53 test456.txt 53 test456.txt 53 test456.txt 53 test456.txt 53 test456.txt 15 C:\Programs\MongoDB\bin> When I do mongofiles get test456.txt I always get the last file which I put with that name in GridFS. How do I get the other/previous ones provided they all have duplicate names? According to the documentation I need to specify: "A filename which is either: the name of a file on your local's file system, or a GridFS object." http://docs.mongodb.org/manual/reference

Configure GridFS Chunksize in MongoDB

元气小坏坏 提交于 2019-12-06 05:51:46
问题 I'm currently investigating to use MongoDB for storing E-Mail data. As E-Mails may become rather big in size (say 10 megs). I believe that GridFS would be a good fit for this. What scares me a bit tough is, that the docs are not very clear about the shard size within gridFS. From what I understand is, that the shard size in gridFS is not equal to the normal shard size but defaults to 256kb. Which sounds to me like a big waste of space, as many e-mails will not exceed 50kb in size. Is there a