0

I have generated XMl file from lotus.domino.Document using generateXML() method.

Below is the fragment of the generated XML.

<item name="$FILE" summary="true" sign="true" seal="true">
   <object>
      <file hosttype="msdos" compression="none" flags="storedindoc" encoding="none" name="13303154.pdf" size="864787">
         <created>
            <datetime dst="true">20210331T164922,93-04</datetime>
         </created>
         <modified>
            <datetime dst="true">20210331T164922,93-04</datetime>
         </modified>
         <filedata>somedatahere</filedata>
      </file>
   </object>
</item>

My question is, how to I get the 13303154.pdf from the data. The data is too long hence not posting here. If required I can also post the data as well.

Thanks in advance

Aniruddha
  • 55
  • 2
  • 10
  • My understanding is that this is base64 encoded data, but it does not directly represent the file. It represents the binary data of the CD Records that the Notes API uses as containers for the file data inside the NSF. In other words, the file data is in there, but it's in a structure that you'll need the Notes API header files in order to interpret correctly. There are a couple of other questions here on StackOverflow that point this out, although the context for those questions is getting at embedded graphics rather than attachments. – Richard Schwartz Jun 11 '21 at 16:23
  • E.g. https://stackoverflow.com/questions/62397332/how-do-i-process-a-dxl-filedata-element-when-the-file-encoding-is-none and https://stackoverflow.com/questions/12003916/lotus-notes-dxl-notesbitmap-to-gif – Richard Schwartz Jun 11 '21 at 16:24
  • Thanks @RichardSchwartz for your support. As in both these links are non conclusive, I am trying to get the file from a different avenue. I don't think there is any direct API for reading the XML data to file. Thanks again for your support. – Aniruddha Jun 12 '21 at 18:20
  • 1
    I just noticed another thing. The XML indicates that seal="true" for the a $FILE item. This means that the document is encrypted and the attachment is within the scope of the encryption. You can't read *anything* out of the encrypted data of a document unless you have the key in your current user ID. This could be a private key or a shared key, depending on how the document was created. – Richard Schwartz Jun 12 '21 at 19:41
  • Thanks @RichardSchwartz. I didn't know about that. I am going to use emobj.extractFile("uniquePath" + File.separatorChar + “attachmentName”); for extracting the attachment. – Aniruddha Jun 15 '21 at 05:13

1 Answers1

0

You can use the getAttachment(String filename) method on Document.

Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
  • Thanks Henrik. I have tried that. I am getting `null` when calling that method. Hence generated XML so the data can be used anytime. Also could not find a way to get name of attachments. `getEmbeddedObjects()` gave blank array. – Aniruddha Jun 11 '21 at 09:04
  • 1
    If I recall correctly, the attachments can either be available through NotesDocument.getEmbeddedObjects or through NotesRichTextField.getEmbedded objects. You have to try both of them. It depends on how the document was attached. But using NotesSession.Evaluate("@AttachmentNames",NotesDocument) will get all attachments regardless of whether they are attached at the document level or in a rich text field. – Richard Schwartz Jun 12 '21 at 19:37