Reputation: 647
I am using images or other times of files in my database as a blob. Once I retrieve that blob I put that in a buffer and convert to base64 like this:
file = Buffer.from(blob,'binary').toString('base64');
res.send(file)
Now, in my jquery :
On success after the post route is fired I want to receive the file:
success: function(data){
console.log(data)
console.log('image uploaded and form submitted');
}
But the console.log
shows that the entire file is just this:
W29iamVjdCBPYmplY3Rd
From my understanding of buffer it is just a small memory allocation used to transfer large sets of data one at a time. So I think I am only getting the first buffer? How do I get the entire buffer?
Upvotes: 0
Views: 248
Reputation: 670
W29iamVjdCBPYmplY3Rd is the base64 for [object Object]
You must check what the blob
is actually, its not a string of data, its a javascript object, contains the whole row of the database, or something else.
The objects.toString() is called when passed into buffer.from
I would suggest using console.log(blob)
and you will be happy.
Upvotes: 1