The problem I have is that I am using nodejs v18.0.0, I have already used skipper-gridfs on other occasions and it works perfectly, the difference is that I have used node v12 or node v14 but this time this version of node is necessary, it is worth mentioning that the I create fs.files collections automatically and fs.chunks I create them manually but it only inserts them into f.chunks. I share my code:
`/**
const get_file = function(blob, fd) {
return new Promise((resolve, reject) => {
blob.read(fd, function(error , file) {
if(error) {
return reject(error);
}
return resolve(file);
});
});
}
module.exports = {
uploadFile: async(request, response)=>{
request.file('archivo').upload({
adapter: require('skipper-gridfs'),
uri: 'mongodb://127.0.0.1:27017/partidas_presupuestales'
}, function (err, filesUploaded) {
if (err) return response.serverError(err);
return response.ok();
});
},
viewdocument: async function( request, response ){
const blobAdapter = require('skipper-gridfs')({
// uri: 'mongodb://apostillado:apostillado2022@10.16.17.141:27017/apostillado'
uri: "mongodb://127.0.0.1:27017/partidas_presupuestales"
});
const fd = request.param('id').split("_").join('.');
const file = await get_file(blobAdapter, fd);
response.contentType('application/pdf');
return response.send(new Buffer(file));
}
};
`
I have already reviewed permissions, the connection string, I have changed the version of skipper-gridfs to a lower one, currently this is the configuration I have:
sailsjs:1.5.2
mongodb:4.2.0
skipper-gridfs: 1.0.2
Likewise, in the endpoint in postman there is POST /upload
header: Content-Type: multipart/form-data
body: form-data
key:file
value: my_file.pdf
The problem I have is that I am using nodejs v18.0.0, I have already used skipper-gridfs on other occasions and it works perfectly, the difference is that I have used node v12 or node v14 but this time this version of node is necessary, it is worth mentioning that the I create fs.files collections automatically and fs.chunks I create them manually but it only inserts them into f.chunks. I share my code:
`/**
*/
const get_file = function(blob, fd) {
return new Promise((resolve, reject) => {
blob.read(fd, function(error , file) {
if(error) {
return reject(error);
}
return resolve(file);
});
});
}
module.exports = {
uploadFile: async(request, response)=>{
request.file('archivo').upload({
adapter: require('skipper-gridfs'),
uri: 'mongodb://127.0.0.1:27017/partidas_presupuestales'
}, function (err, filesUploaded) {
if (err) return response.serverError(err);
return response.ok();
});
},
viewdocument: async function( request, response ){
const blobAdapter = require('skipper-gridfs')({
};
`
I have already reviewed permissions, the connection string, I have changed the version of skipper-gridfs to a lower one, currently this is the configuration I have:
sailsjs:1.5.2
mongodb:4.2.0
skipper-gridfs: 1.0.2
Likewise, in the endpoint in postman there is POST /upload
header: Content-Type: multipart/form-data
body: form-data
key:file
value: my_file.pdf