On Tuesday I was bemoaning the lack of a way to stream binary data directly to the browser from an Agent. Me, moaning? Surely not!
Despite the fact nobody knew of a way to stream data directly I did manage to get something out of the whole exercise. What came of it is a way to generate, store and (optionally) email automatically generated files without using the server's disk.
So what? Well, not needing to write to the disk means you don't need to worry about who signed the agent last and/or what access the ID has to the server. Any old developer can now write an agent that works with file generation!
As an example, here's a form that will generate and attach a PDF to itself during the WQS event. It can even email it, as you can see to the right.
You'll just have to trust me for the time being that the agent is run without unrestricted rights.
The demo form also does the same thing with a text file and an Excel file!
I can't show you a CAPTCHA demo online as this server is Linux and without X11 running it can't use the Java graphics libraries.
Although the approach is the same for them all the difference between the Text/Excel and Image/PDF is that they are based on text and binary data respectively.
Generating the text files, as you'd imagine, is easier and can be achieved with a small amount of LotusScript. Here's the code needed in a WQS agent to attach a text file.
Generating binary files like the PDF requires Java (we need to use a ByteArrayOutputStream as a temporary buffer). Here's some commented code that's an abstract from the WQS of the above demo.
There's probably more detail that's worth discussing further and so I'll probably write a full-length article on the topic.
Next week I'll outline how you go about downloading the DEXT app that the demos live in. In the mean time have a play with the demo. Don't abuse the send-email feature though please! I'll be keeping an eye on its usage and will cut it off if used badly.