<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ArcObjects Java IMemoryBlobStream in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338785#M8890</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written a Java addin tool to open all attachments on a point feature in the PCs default image viewer.&lt;/P&gt;&lt;P&gt;I was using the Working with Attachments, &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Working_with_feature_attachments/0001000001qr000000/" title="http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Working_with_feature_attachments/0001000001qr000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;ArcObjects Help for .NET developers&lt;/A&gt; , as a starting example to achieve this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I use the code snippet below, it successfully loops through all the attachments reading the name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ITableAttachments attachTable;
attachTable = new ITableAttachmentsProxy(pFeatureClass);
IAttachmentManager attachMan = attachTable.getAttachmentManager();
ILongArray IdArray = new LongArray();
IdArray.add(OID);
IEnumAttachment attachEnum = attachMan.getAttachmentsByParentIDs(IdArray, true);
attachEnum.reset();
IAttachment attach = attachEnum.next();
while (attach != null){
 System.out.printf("%s,: %s\n", attach.getAttachmentID(), attach.getName() );
 IMemoryBlobStream memBlob = attach.getData();
 memBlob.saveToFile(attach.getName());
 attach = attachEnum.next();
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it fails to save the &lt;STRONG&gt;IMemoryBlobStream&lt;/STRONG&gt; to file with the error,&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;java.lang.NullPointerException&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;which implies the blob data was not retrieved from the attachment table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any pointer on where I am going wrong would be much appreciated,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Owain&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:01:53 GMT</pubDate>
    <dc:creator>OwainCatton</dc:creator>
    <dc:date>2021-12-11T16:01:53Z</dc:date>
    <item>
      <title>ArcObjects Java IMemoryBlobStream</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338785#M8890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written a Java addin tool to open all attachments on a point feature in the PCs default image viewer.&lt;/P&gt;&lt;P&gt;I was using the Working with Attachments, &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Working_with_feature_attachments/0001000001qr000000/" title="http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Working_with_feature_attachments/0001000001qr000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;ArcObjects Help for .NET developers&lt;/A&gt; , as a starting example to achieve this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I use the code snippet below, it successfully loops through all the attachments reading the name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ITableAttachments attachTable;
attachTable = new ITableAttachmentsProxy(pFeatureClass);
IAttachmentManager attachMan = attachTable.getAttachmentManager();
ILongArray IdArray = new LongArray();
IdArray.add(OID);
IEnumAttachment attachEnum = attachMan.getAttachmentsByParentIDs(IdArray, true);
attachEnum.reset();
IAttachment attach = attachEnum.next();
while (attach != null){
 System.out.printf("%s,: %s\n", attach.getAttachmentID(), attach.getName() );
 IMemoryBlobStream memBlob = attach.getData();
 memBlob.saveToFile(attach.getName());
 attach = attachEnum.next();
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it fails to save the &lt;STRONG&gt;IMemoryBlobStream&lt;/STRONG&gt; to file with the error,&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;java.lang.NullPointerException&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;which implies the blob data was not retrieved from the attachment table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any pointer on where I am going wrong would be much appreciated,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Owain&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:01:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338785#M8890</guid>
      <dc:creator>OwainCatton</dc:creator>
      <dc:date>2021-12-11T16:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: ArcObjects Java IMemoryBlobStream</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338786#M8891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Owain,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like the parameter value provided to the &lt;STRONG&gt;saveToFile &lt;/STRONG&gt;method needs to be &lt;SPAN style="text-decoration: underline;"&gt;a folder path&lt;/SPAN&gt;, not the name of the file being saved.&amp;nbsp; I haven't worked with these interfaces before, but looking at &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//004900000059000000"&gt;this snippet&lt;/A&gt; I think it might be the change you need to make.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Feb 2015 16:02:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338786#M8891</guid>
      <dc:creator>ErinBrimhall</dc:creator>
      <dc:date>2015-02-25T16:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: ArcObjects Java IMemoryBlobStream</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338787#M8892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Erin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That unfortunately using a folder or full path string does not work either &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as I can tell the IAttachment.getData() is not retrieving the blob data into the IMemoryBlobStream hence the NULL pointer.&lt;/P&gt;&lt;P&gt;As any attempt to get information on the IMemoryBlobStream fails as its is NULL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try and use the snippet mentioned to see if that works,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Owian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2015 10:02:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338787#M8892</guid>
      <dc:creator>OwainCatton</dc:creator>
      <dc:date>2015-02-26T10:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: ArcObjects Java IMemoryBlobStream</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338788#M8893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For those that are interested, I have managed to get this working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although I ended up getting the Blob data directly from the table and not relying on the IAttachmentManager to retrieve it for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ITableAttachments attachTable;
attachTable = new ITableAttachmentsProxy(pFeatureClass);
IAttachmentManager attachMan = attachTable.getAttachmentManager();
ILongArray IdArray = new LongArray();
IdArray.add(OID);
IEnumAttachment attachEnum = attachMan.getAttachmentsByParentIDs(IdArray, true);
attachEnum.reset();
IAttachment attach = attachEnum.next();
ArrayList&amp;lt;String&amp;gt; imgList = new ArrayList&amp;lt;String&amp;gt;();
while (attach != null){
 String aPath = System.getenv("TEMP")+attach.getName();
 IDataset pDataset = (IDataset) pFeatureLayer;
 String tablePath = pDataset.getWorkspace().getPathName();
 IWorkspaceFactory pWorkspaceFact = new FileGDBWorkspaceFactory();
 IWorkspace pWorkspace = pWorkspaceFact.openFromFile(tablePath, 0);
 IFeatureWorkspace pFtWorkspace = (IFeatureWorkspace) pWorkspace;
 ITable pTable = pFtWorkspace.openTable(pDataset.getBrowseName()+"__ATTACH");
 IRow pRow = pTable.getRow(attach.getAttachmentID());
 IMemoryBlobStream memoryBlobStream = (IMemoryBlobStream) pRow.getValue(5);
 memoryBlobStream.saveToFile(aPath);
}&lt;/PRE&gt;&lt;P&gt;Hope this is some help to other people,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Owain&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:01:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338788#M8893</guid>
      <dc:creator>OwainCatton</dc:creator>
      <dc:date>2021-12-11T16:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: ArcObjects Java IMemoryBlobStream</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338789#M8894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice, thanks for posting this solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2015 15:43:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcobjects-java-imemoryblobstream/m-p/338789#M8894</guid>
      <dc:creator>ErinBrimhall</dc:creator>
      <dc:date>2015-02-26T15:43:04Z</dc:date>
    </item>
  </channel>
</rss>

