I have a question concerning the example. I am new to feathersjs so it is probably something I misunderstood, but in the example, the function that take a file to turn it into a datauri for blobservice is called inside a BEFORE hook. I thought before hooks where called before the service, to witch it applies, run. So how can this before hook handle the file created by multer from multipart data (with the function call: multipartMiddleware.single('uri')) if this part of the code have not been executed yet?
Or is it than in the case of multiple middelware functions called into the app.use() function, the before hooks would be inserted between the second to last and the last function? (I thought it would be called before any middelware function called by app.use() )
app.use('/uploads',
blobService({Model: blobStorage})
);
app.service('/uploads').before({
create: [
function(hook) {
if (!hook.data.uri){
multipartMiddleware.single('uri'), //don't know how to call multer here has I don't know if hooks have access to req, res and next.
if ( req.file)
{
const file = req.file;
const uri = dauria.getBase64DataURI(file.buffer, file.mimetype);
hook.data = {uri: uri};
}
}
}
]
});
which should be proper as multer needs to be called only in the 'create' function of the service and not in the 'get' one for example