I'm creating a view similar to a form where the user can fill in text fields, select buttons, and upload files. I want to store all this into a database with a 'submit' button click. However I can't figure out how to store the bytes of the file that the user uploaded to database on the submit button click.
I've been able to store the file bytes to the database by itself with the file upload component's onFileReceieved script by using event.file.getBytes(), so I know it's possible. But I want to store the bytes, along with all the other user input, to the database in one query on the submit button click. I can't figure out how to reference the bytes of the file outside of its own event script. How can I accomplish this?
I think you'll have to do something like write the file to a temp location in onFileReceived, then store that location as a session prop that you can access when the submit button is clicked. You'll have to read the bytes back from that temporary file.
You might find my viewVarMap(), pageVarMap(), or sessionVarMap()functions helpful for this kind of temporary storage. All part of my Integration Toolkit module.
Oy! Dangerous (easy to screw up the cleariing step), and will have clashes when two different clients upload files with the same name.
Use an actual temporary file, or a temporary row in a database, before you use system.util.getGlobals(). There be dragons. My integration toolkit functions exist specifically to slay those dragons.