gridfs

GridFS: Clean out all unreferenced files

北慕城南 提交于 2019-12-12 19:24:21
问题 I have just moved towards storing things in my GridFS in MongoDB. During testing, I noticed many files are being created but not deleted properly. I have a collection users , which has a field avatar . It contains the ObjectId of the file. Now I'd like to have some command I could use to remove all the files and chunks that are not referenced there. Is it possible to do that with one query? Maybe 'map-reduce'? Also I am not sure how to properly delete GridFS-Files in node-mongodb-native

Find the latest version of a document stored in MongoDB - GridFs

折月煮酒 提交于 2019-12-12 10:24:20
问题 I'm planning to use MongoDB GridFs to store different types of flat files, scripts etc. One of the benefits using GridFs is that it creates new document on every insert and thus can be used for versioning purposes using custom meta data etc. However, how to ensure the fetched document is the latest document from GridFS ? Appreciate any suggestions. 回答1: For any given criteria, GridFS always brings the latest version with findOne. You can test it. Have lots of files with same 'filename' field.

Creating file in GridFs (MongoDb)

拟墨画扇 提交于 2019-12-12 06:49:48
问题 I have two collections, LogData and OptData. LogData is having just 600 records whereas OptData is having around 3 million records. To make some logical data, I am trying to merge both colletions. But merging simply by using mongo command create a document larger in size than 16 MB. Can I merge files using GridFs? My collections are like LogData [{ "SId": 10, "NoOfDaya" : 9 } { "SId": 11, "NoOfDaya" : 8 }] OptData [ { "SId": 10, "CId": 12 } { "SId": 10, "CId": 13 }] I want something like

How to create a CDN server in dotnet core using MongoDB GridFS and AngularJs

坚强是说给别人听的谎言 提交于 2019-12-12 04:58:53
问题 We want to create a decoupled file server named CDN in .net core using MongoDB GridFS and angular js. From various sources I tried my best to solve the issue. And finally we done this. 回答1: I used Visual Studio 2017 and .NETCore 1.1 To do so I follow the followings: 1. Write Code in MongoDB GridFS create an interface like public interface IGridFsRepository : IDisposable { Task<string> UploadAsync(IFormFile file); Task<bool> AnyAsync(ObjectId id); Task<bool> AnyAsync(string fileName); Task

Error on large files with GridFS and MongoDB

假装没事ソ 提交于 2019-12-12 03:43:55
问题 I seem to be getting an error when trying to upload large files into MongoDB.. Fatal error: Uncaught exception 'MongoGridFSException' with message 'could not open file ' in /home/jclark/thundergrid.fusionstrike.com/thundergrid/thundergrid.php:33 Stack trace: #0 /home/jclark/thundergrid.fusionstrike.com/thundergrid/thundergrid.php(33): MongoGridFS->storeUpload('pic', Array) #1 /home/jclark/thundergrid.fusionstrike.com/thundergrid/admin/index.php(7): Admin->upload() #2 {main} Next exception

Can you use find queries on GridFS using javascript API?

梦想与她 提交于 2019-12-11 18:24:09
问题 As I understand it, when you enter something into GridFS it gets entered into 2 different collections under the hood. One for the raw chunks of data and one for the meta data files. Also from what I understand from MongoDB's documentation is that you can only retrieve a document from GridFS with an id or name. var gs = new mongodb.GridStore(db, "test.png", "w", { "content_type": "image/png", "metadata":{ "author": "Daniel" }, "chunk_size": 1024*4 }); So what if I want to get a subset of

Unable to read() from gridfs with python in Windows

[亡魂溺海] 提交于 2019-12-11 18:04:29
问题 I use pylons framefork and store some images in the gridfs. This code works perfect for MacOS and Linux servers f = self._fs.get(ObjectId(image)) # In linux unicode u'image/jpg' raise error, thats why I use str() for content-type response.headers['Content-type'] = str(f.content_type) return f.read() In Windows I get an error "Unable to read image". What the reason? 来源: https://stackoverflow.com/questions/9708288/unable-to-read-from-gridfs-with-python-in-windows

MEAN : Serve File from GridFs

北战南征 提交于 2019-12-11 16:08:21
问题 I am using MEAN stack and I am trying to serve a file stored using Mongo GridFs. This is the code I have tried so far. exports.getFile = function(req, res) { var fileId = req.params.fileId; gfs.findOne({ _id: fileId }, function (err, file) { if (err) { res.status(500).send(err) } console.log('file meta', file); res.header("Content-Type", file.contentType); var readstream = gfs.createReadStream({ filename: file.filename }); //error handling, e.g. file does not exist readstream.on('error',

Stuck at changing binary data to base64 (Gridfs-stream)

我们两清 提交于 2019-12-11 12:31:57
问题 I am trying to change some binary data from my uploaded images to base64 so I can use that to display an image. But the terimal is giving me this error: TypeError: Cannot read property 'on' of undefined I don't understand, when I post I also use the .on event and it is working fine. Besides that, I wonder if I am correctly changing the data. Please take into account that I'm fairly new to node :) How I save a uploaded image (POST) // Post to profile page router.post('/', function(req, res,

Dropzone file not fully processed when calling processFile(File)

六眼飞鱼酱① 提交于 2019-12-11 11:58:46
问题 I'm creating a Dropzone programmatically in my Meteor application and instead of posting Files to a url I'm storing them inside my MongoDB with CollectionFS / GridFS and call processFile(File) for each one by iterating over the getQueuedFiles array, like so: dz.getQueuedFiles().forEach(function(element) { Images.insert(element, function(err, fileObj){ if (err){ alert("Erreur!"); } else { var imageId = fileObj._id; arrayOfImageIds.push(imageId); dz.processFile(element); } }) All goes well