Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skipper-gridfs with node v18 #46

Open
rupertomelher89 opened this issue Mar 5, 2024 · 0 comments
Open

skipper-gridfs with node v18 #46

rupertomelher89 opened this issue Mar 5, 2024 · 0 comments

Comments

@rupertomelher89
Copy link

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:[email protected]: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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant