I need to store a pdf (each pdf will be < 5 pages maximum) in a mySQL database (yes I know this is not recommended). The column is defined as mediumblob. The test pdf is 198 KB. I get the error "Errors occurred in addMedicalPlan: java.io.FileNotFoundException: " followed by a dump of the file " JVBERi0xLjcKCjQgMCBvYmoKKElkZW50aXR5KQplbmRvYmoKNS ......" and at the end "(The filename or extension is too long)".
I have managed to do this with images and have been trying to re-purpose that code to store the pdf; by researching articles and other questions. Unfortunately, for me, most of the example relate to PHP. I have been able to read the pdf and display it in the page with this code:
Do I need to strip off "data:application\/(pdf);base64", i.e., img2 = (img1.getAttribute('src')).replace(/^data:application\/(pdf);base64,/, ""); for the pdf? I do similar for storing my images (i.e., img2 = (img1.getAttribute('src')).replace(/^data:image\/(png|jpg|jpeg|gif);base64,/, "");). Is this superfluous for pdf files?
I then pass the pdf to be stored with ajax:
And the server side java is:
I am not a programmer and am doing this pro-bono and learning as I go for my organisation.