This is the getFile function I wrote. Using it-to-buffer to access file chunks.
async function getFile(cid){
let content = await toBuffer(client.cat(cid));
return content;
}
const getFileFromNet = async(cid)=>{
return await getFile(cid);
}
This is the server.js code referencing the exported module getFileFromNet. I am using express.js and firebase.database
app.post("/profile", async function (req, res){
const current_user = req.body;
const uid = current_user.uid;
console.log("User ID: "+uid);
db.ref("user_file_ref").on("value",snapshot=>{
snapshot.forEach(dataSnapshot=>{
if(uid == dataSnapshot.val().user_id){
let loggable = getFileFromNet(dataSnapshot.val().ipfs_ref);
console.log(loggable) ;
}
})
})
});
The console log is as follows
- User ID: w25eDefrvuaq5SNzjYGk6MQrfZf2
- Promise { }
- Promise { }