0

I have the typical form to register a record (VUE.JS).

One of its fields is an 'input type = file'.

I am able to upload a file, send it to the server (Java), and register it in the database (mongo) along with the rest of the fields.

The user can return to this same page, but in edit mode. (Do some changes and save it again..)

And this is where I have the problem: I am able to load the input file with the name of the file that I retrieve from the database (“fileName”). BUT not the binary data itself of the file (“fileData”).

The ‘data’ related to the file is available at this point in the frontend as this JSON object:

{
"fileName" : "DocPrueba (1).PDF",
"fileData" : "JVBERi0xLjcNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0N …. Omited  lots of chars like this…."
}
JLLMNCHR
  • 1,551
  • 5
  • 24
  • 50
  • that looks a lot like base64 encoded data... could you elaborate - what is it you want to allow the user to do? Afaik you can't "edit" a file input element. and reattaching the file before the user looks at the page doesn't make sense. the only thing i can think of is allowing the user to download the file, and reupload, or displaying it's contents in some sort of frame...if it's always a pdf - maybe like an `` element - se https://stackoverflow.com/questions/17784037/how-to-display-pdf-file-in-html. – JoSSte Nov 25 '20 at 09:19
  • Its always pdf file stored as binary data, but not in base64 – JLLMNCHR Nov 25 '20 at 09:55
  • 1
    This may help: https://stackoverflow.com/questions/41008024/how-to-create-a-modified-copy-of-a-file-object-in-javascript – JM-AGMS Nov 25 '20 at 14:16
  • I finally adopted another strategy based in some kind of ID's associatted to FILES that the app controls internally. – JLLMNCHR Nov 26 '20 at 13:55

0 Answers0