I had the necessity to extract an image that is embedded in the database an a resource out to the file system.
What ensued was a lot of fun with DXL, XML and Base 64 encoding.
In the end it's a pretty simple process.
- Find the NoteID for the image resource
- Build the DXL export collection
- Export the DXL
- Parse the DXL XML file
- Locate the Base 64 encoded image in the XML
- Decode the Base 64 encoded image
- Write the decoded image to disk
- Use accordingly
Attached is the Java code to perform the above (step 8 excluded).
There are 3 parameters to the main function (ImageResourceExtractor.extract()
).
- The Lotus Notes session (in an agent's main body this is simply
getSession()
) - The name of the image resource you want to extract
- Where you want the image resource to be extracted to
The function returns a java.io.File
object pointing to the newly exported file.
Enjoy!
File resource missing