Open gfelot opened 7 years ago
the same issue . Did you solve it?
As you want to write to GridFS, you should use Grid.createWriteStream
instead of Grid.createReadStream
.
Then, using fs
to read the content of your file fs.createReadStream(filePath).pipe(writestream)
to actually write the content of the file to GridFS.
pub.hook.js
... create: [ hook => { const gfs = hook.app.get('gfs'); const file = hook.params.file;
console.log(hook)
const writestream = gfs.createWriteStream({
filename: file.originalname,
content_type: file.mimetype, // image/jpeg or image/png
});
fs.createReadStream(filePath).pipe(writestream);
}
],
...
Need to store picture with my API using FeatherJS.
I got the error
MongoError: file with id ### not opened for writing.
with ### is the name of the current file. Do I have to set up manually the ObjectId of the metadata written inside mongo ?
my code for my
/pub
service (if you are familiar with feathersJS):What did I miss ?