Binary data from mongodb gets corrupted - node.js

When I upload a photo it converts to base64 and then when I send to mongodb using Mongoose it saves as Binary. But when I call the same picture back from the database it returns as Buffer array. After converting to base64 it returns as a base64 string but completely different from the original base64. The new base64 is unable to be rendered in browser because it has been corrupted.
Below are pictures of the different strings
This is the initial base64
This is the Buffer array
This is the corrupted base64 after converting from the buffer array using Buffer.from(avatar).toString('base64').
Please note that I appended to it "data:image/png;base64," before rendering in the browser and it still did not render.
Please can someone tell me what I am doing wrong?

the best solution is convert to png or jpg file and upload only path and save image to folder.

Here is how I solved it.
I converted from binary to utf8 instead of to base64.
There is a huge difference bewteen
Buffer.from(binary_data, 'binary').toString('utf8')
and
Buffer.from(binary_data, 'binary').toString('base64')

Related

Convert BASE64 String to PDF file in the IFS on AS400

We receive a BASE64 encoded representation of a courier label PDF in an xml file, which we store in the IFS of our AS400.
We would like to decode this BASE64 string and save it as a .PDF in the IFS so we can then either email it as an attachment or send it to a printer.
I have looked at the capability of the CPYSPLF command using the *PDF WSCST parameter, but this only seems relevant where we would have a Spooled File representation of the label we want to produce.
Does anyone know if this is possible via native iSeries commands/RPG?
One way is to
IFS_READ_UTF8 to load the XML file
XMLPARSE to make it a XML object
XML_TABLE to extract BASE64 data
BASE64_DECODE to decode B64 data to PDF binary stream
IFS_WRITE_BINARY to write that stream as a .pdf file
You could make it a pure sql prodecure, or a SQLRPGLE program.
You also could extract BASE64 date using RPGLE XML-INTO. The use Scott Klement's BASE64 SRVPGM to decode it, then write it to the IFS

Convert Binary content of PDF file To JSON format using node.js

we want Json format from binary content of pdf file using node.js.
Actually we are getting binary content of pdf from 3 party api response , using this response we will save in our database ,so give me working code for convert binary pdf format to json format
in simple words
Please let us know , "any working code so i have just pass binary data got json data" .
The JSON format natively doesn't support binary data.
Use Base64 or base85
I think the best you can do space-wise is base85 which represents four bytes as five characters. However, this is only a 7% improvement over base64, it's more expensive to compute, and implementations are less common than for base64 so it's probably not a win.

Converting a nodejs buffer to string and back to buffer gives a different result in some cases

I created a .docx file.
Now, I do this:
// read the file to a buffer
const data = await fs.promises.readFile('<pathToMy.docx>')
// Converts the buffer to a string using 'utf8' but we could use any encoding
const stringContent = data.toString()
// Converts the string back to a buffer using the same encoding
const newData = Buffer.from(stringContent)
// We expect the values to be equal...
console.log(data.equals(newData)) // -> false
I don't understand in what step of the process the bytes are being changed...
I already spent sooo much time trying to figure this out, without any result... If someone can help me understand what part I'm missing out, it would be really awesome!
A .docXfile is not a UTF-8 string (it's a binary ZIP file) so when you read it into a Buffer object and then call .toString() on it, you're assuming it is already encoding as UTF-8 in the buffer and you want to now move it into a Javascript string. That's not what you have. Your binary data will likely encounter things that are invalid in UTF-8 and those will be discarded or coerced into valid UTF-8, causing an irreversible change.
What Buffer.toString() does is take a Buffer that is ALREADY encoded in UTF-8 and puts it into a Javascript string. See this comment in the doc,
If encoding is 'utf8' and a byte sequence in the input is not valid UTF-8, then each invalid byte is replaced with the replacement character U+FFFD.
So, the code you show in your question is wrongly assuming that Buffer.toString() takes binary data and reversibly encodes it as a UTF8 string. That is not what it does and that's why it doesn't do what you are expecting.
Your question doesn't describe what you're actually trying to accomplish. If you want to do something useful with the .docX file, you probably need to actually parse it from it's binary ZIP file form into the actual components of the file in their appropriate format.
Now that you explain you're trying to store it in localStorage, then you need to encode the binary into a string format. One such popular option is Base64 though it isn't super efficient (size wise), but it is better than many others. See Binary Data in JSON String. Something better than Base64 for prior discussion on this topic. Ignore the notes about compression in that other answer because your data is already ZIP compressed.

Is it possible to get actual cropped PNG from Croppie instead of the base64 encoding?

I am using Croppie to crop an image and it is giving me base64 which creates 413 error while sending it on server for large images, so I need proper image file. I tried to find converting it(base64) as a image file locally at client side but didn't get expected way for conversion using javascript/jquery.
Please guide me.

Disociate an image and text from a base64 encoded string

I'm coding an API in ASP.NET that receives base64 encoded string to parse them into a DB. My problem is the following : these strings contain both an image and some text following it and I cannot find a way to separate them to then process he text part. Of course I have no possibility of changing the format.. So I was wondering if someone had an idea or a tool to detect the begining and end of the image and the text par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H______4P_____AAAB____4AAAD____AAA__AAAH_4AAAAAAAAAAAB______-D_____8AAB_____AAAD____8AAP_4AAB_-AAAAAAAAAAAAf______g______wAA_____4AAB_____gAD__AAAf_gAAAAAAAAAAAH______4P_____-AAf_____gAA_____8AA__wAAH_4AAAAAAAAAAAB______-D______wAP_____4AAf_____wAP_-AAB_-AAAAAAAAAAAAf______g______-AD______AAP_____8AD__gAAf_gAAAAAAAAAAAH______4P______wB______4AH______gA__8AAH_4AAAAAAAAAAAB______-D______-A__4AP_-AD__8D__8AP__gAB_-AAAAAAAAAAAAf_gAAAAA__AAf__wP_4AA__wA__4AH__gD__4AAf_gAAAAAAAAAAAH_4AAAAAP_wAAf_8D_8AAH_8Af_4AAf_4A___AAH_4AAAAAAAAAAAB_-AAAAAD_8AAB__g_-AAA__AP_8AAD__AP__wAB_-AAAAAAAAAAAAf_gAAAAA__AAAP_4f_gAAP_wD_-AAAf_wD__-AAf_gAAAAAAAAAAAH_4AAAAAP_wAAB_-H_4AAB_-A__AAAD_-A___wAH_4AAAAAAAAAAAB_-AAAAAD_8AAAf_h_-AAAf_gf_wAAAf_gP__8AB_-AAAAAAAAAAAAf_gAAAAA__AAAD_4f_gAAH_4H_4AAAH_4D___gAf_gAAAAAAAAAAAH_4AAAAAP_wAAA__H_8AAAAAD_-AAAA__A___4AH_4AAAAAAAAAAAB_-AAAAAD_8AAAP_w__AAAAAA__AAAAP_wP___AB_-AAAAAAAAAAAAf_gAAAAA__AAAD_8P_8AAAAAP_wAAAD_8D_7_4Af_gAAAAAAAAAAAH_4AAAAAP_wAAA__D__wAAAAD_8AAAAf_A_-_-AH_4AAAAAAAAAAAB_-AAAAAD_8AAAP_w___wAAAA_-AAAAH_4P_v_wB_-AAAAAAAAAAAAf_____4A__AAAD_8H___gAAAf_gAAAB_-D_5_8Af_gAAAAAAAAAAAH______gP_wAAA_-B____gAAH_4AAAAf_g_-f_gH_4AAAAAAAAAAAB______4D_8AAAf_gP____gAB_-AAAAH_4P_j_8B_-AAAAAAAAAAAAf_____-A__AAAP_4B_____AAf_gAAAA_-D_4__Af_gAAAAAAAAAAAH______gP_wAAH_-AP____8AH_4AAAAP_g_-H_4H_4AAAAAAAAAAAB______4D_8AAD__AB_____wB_-AAAAD_4P_h_-B_-AAAAAAAAAAAAf_____-A__AAD__wAH____-Af_AAAAA_-D_4P_wf_gAAAAAAAAAAAH______gP_4Af__4AAf____wH_wAAAAP_h_-D_8H_4AAAAAAAAAAAB______4D______-AAA____-B_-AAAAD_4f_gf_h_-AAAAAAAAAAAAf_____-A_______AAAB____wf_gAAAA_-D_4H_4f_AAAAAAAAAAAAH_4AAAAAP______gAAAB___-H_4AAAAP_h_-A__H_wAAAAAAAAAAAB_-AAAAAD______wAAAAB___h_-AAAAH_4P_gH_x_8AAAAAAAAAAAAf_gAAAAA______4AAAAAD__8f_gAAAB_-H_4B_-f_AAAAAAAAAAAAH_4AAAAAP_____8AAAAAAP__H_4AAAAf_h_-AP_n_wAAAAAAAAAAAB_-AAAAAD_____8AAAAAAA__w_-AAAAH_4f_gD_9_8AAAAAAAAAAAAf_gAAAAA_____8AAAAAAAH_8P_wAAAD_8D_4Af_f_AAAAAAAAAAAAH_4AAAAAP____4AAf_gAAA__D_8AAAA__B_-AD_7_wAAAAAAAAAAAB_-AAAAAD_8AAAAAH_4AAAH_w__AAAAP_wf_gA_-_8AAAAAAAAAAAAf_gAAAAA_-AAAAAB_-AAAB_8H_4AAAH_8H_4AH___AAAAAAAAAAAAH_4AAAAAP_gAAAAAP_gAAAf_B_-AAAB_-A_-AB___wAAAAAAAAAAAB_-AAAAAD_4AAAAAD_8AAAH_wf_wAAA__gf_gAP__8AAAAAAAAAAAAf_gAAAAA_-AAAAAA__AAAB_8D_-AAAP_wH_4AB___AAAAAAAAAAAAH_4AAAAAP_gAAAAAP_4AAA__A__wAAH_8B_-AAf__wAAAAAAAAAAAB_-AAAAAD_4AAAAAB__AAAf_wH_-AAD_-Af_gAD__8AAAAAAAAAAAAf______g_-AAAAAAf_8AAP_4B__wAD__gH_4AA___AAAAAAAAAAAAH______4P_gAAAAAH__wAf_-AP__AD__wB_-AAH__wAAAAAAAAAAAB______-D_4AAAAAA_______AB______8Af_gAA__8AAAAAAAAAAAAf______g_-AAAAAAH______wAf_____-AH_4AAP__AAAAAAAAAAAAH______4P_gAAAAAA______4AD______AB_-AAB__wAAAAAAAAAAAB______-D_4AAAAAAH_____8AAf_____gAf_gAAf_8AAAAAAAAAAAAf______g_-AAAAAAA_____-AAD_____wAH_4AAD__AAAAAAAAAAAAH______4P_gAAAAAAH_____AAAP____4AB_-AAA__wAAAAAAAAAAAB______-D_4AAAAAAAf____AAAB____4AAP_gAAH_8AAAAAAAAAAAAf______g_-AAAAAAAB____AAAAH___4AAD_4AAA__AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD__-AAAAAf__4AAA_-AAAP_wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH_0AAAAAA__gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf_HAQD4AgEIEgIAAAAAAgAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAdKEwCADAyG3QACht0AEVQU09OIEVVUk9QRSBTSE9QG3QACht0AE90dG8tSGFobiA0G3QACht0AE1lZXJidXNjaBt0AAobdAA0OSA1NTUgNTg0IDExOTUbdAAKCht0AFRoYW5rIHlvdSBmb3Igc2hvcHBpbmcbdAAKG3QAUGxlYXNlIHZpc2l0IHVzIGFnYWluIHNvb24bdAAKCht0ADIwMTUvMTAvMzAgMTg6MTkbdAAKG3QACht0AEVQU09OIFdvcmtGb3JjZSBXUC00G3QAICAxG3QAIBt0ACAgICAgICAgIBt0EIAyNjIbdBAKCh0hEBt0EE5FVB0hABt0ECAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIIAyNTAbdBAKHSEQG3QQVEFYHSEAG3QQICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIIAxMht0EAodIRAbdBBUT1RBTBt0ECAgICAgICAgICAggDI2Mh0hABt0EAoKG3QQQ0FTSBt0ECAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICCAMzAwG3QQCh0hEBt0EENIQU5HRRt0ECAgICAgICAgICAggDM4HSEAG3QQCgobYQEbZAMdVkIA
I cannot comment, so I post this as an answer:
You could decode the base64 encoded string to binary and try to detect the magic number of the image (assuming it has one). if it is an JPEG image it has a start and end signature. a BMP has the size of the image encoded into the header.

Resources