Posts

Showing posts with the label Node

Use node which-country

Image
I  need to take the users country based on the geo-codinates provided by the mobile application. whlile doing some reaserch in node which-country , I found that ituseful,but need to pass value wisely.  https://www.npmjs.com/package/which-country  var whichCountry = require('which-country'); // pass it as  [latitudes,logitudes] var userCountry = whichCountry([6.795019389999998,79.88569332999997]); console.log('test userCountry :'+userCountry);  //return null // pass it as [logitudes,latitudes] var userCountry = whichCountry([79.88569332999997,6.795019389999998]); console.log('test userCountry :'+userCountry);  //return LKA I test the application with the given code of me in the test packges given by them. https://github.com/vkurchatkin/which-country/blob/master/package.json AUS -22.000825,132.889122 BLR 52.337547,24.080529 CAN 57.255393,-106.712553 CYP 35.315045,33.681395 DZA 23.184085,7.117638 ITA 39.926747,9.017427 JPN 43.771243,142.764986

Uplaod to Firebase Storage from Node Express REST

Image
I need to upload user profile picture from mobile device trogh rest API to Firebase storage .Finally I go the follwing articale wich really guide me .  https://mzmuse.com/blog/how-to-upload-to-firebase-storage-in-node In order to upload the file from Express REST I used connect-busboy and fs node modules . Route file   router.post('/api/user-pic/profile-type/:type', ProfilePicController.setProfile); Controller File    exports.setProfile = function(req, res, next) {                     var fstream;                     req.pipe(req.busboy);                     req.busboy.on('file', function (fieldname, file, filename) {                                           console.log("Uploading: " + filename);                         fstream = fs.createWriteStream(__dirname + '/files/' + filename);                               file.pipe(fstream);                         const filePath = __dirname + '/files/' + filename;