<?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 Re: layer.attachments.download doesn't work for sublayers in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1413520#M70414</link>
    <description>&lt;P&gt;&amp;nbsp;Hi, thank you very much for your reply!&lt;/P&gt;&lt;P&gt;I was not in the office so I could not get back to you earlier. Please excuse the delayed answer!&lt;/P&gt;&lt;P&gt;Yes, we are accessing a feature service!&lt;/P&gt;&lt;P&gt;We tested your code and it works just fine on a simple point feature service with one related table. The feature service is branch versioned.&lt;/P&gt;&lt;P&gt;However, we applied the code on a feature service which has at least 15 related tables which each of may include an attachment. In that case, the code fails, unfortunately.&lt;/P&gt;&lt;P&gt;Just in case, I am providing a screenshot of the table properties:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PolzinFiona_0-1713796660633.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101692i43E3AB899C952382/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PolzinFiona_0-1713796660633.png" alt="PolzinFiona_0-1713796660633.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;....and a screenshot of the settings applied before publishing the feature service:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PolzinFiona_1-1713796695474.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101693i3F9B0BC42F479121/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PolzinFiona_1-1713796695474.png" alt="PolzinFiona_1-1713796695474.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Do you know whether there is a limitation regarding the number of related tables? Is it possible to use a code which looks up every single table related to one feature service to verify whether it has an attachment ? If it is possible, how is it possible to access it?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2024 14:42:05 GMT</pubDate>
    <dc:creator>PolzinFiona</dc:creator>
    <dc:date>2024-04-22T14:42:05Z</dc:date>
    <item>
      <title>layer.attachments.download doesn't work for sublayers</title>
      <link>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407055#M70272</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I have an ArcGIS Portal (11.1) referenced Feature Layer that has several sublayers. One of the layers contains photo attachments.&lt;/P&gt;&lt;P&gt;I've had success whenever attachments are not in a sublayer using layer.attachments.download.&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I'm stuck trying to figure out how to download the photos given in a sublayer.&lt;/P&gt;&lt;P&gt;Do you know whether there is an option to access sublayers and download their attachments?&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 11:18:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407055#M70272</guid>
      <dc:creator>PolzinFiona</dc:creator>
      <dc:date>2024-04-08T11:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: layer.attachments.download doesn't work for sublayers</title>
      <link>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407109#M70274</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/517851"&gt;@PolzinFiona&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Can you &lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_self"&gt;post&lt;/A&gt; an example of the code your using?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 13:38:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407109#M70274</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-04-08T13:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: layer.attachments.download doesn't work for sublayers</title>
      <link>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407111#M70275</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10527"&gt;@JakeSkinner&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;thank you for your quick reply. This is the code I'm using:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os
import shutil
from arcgis.gis import GIS
PortalUrl = ""
username = ""
password = ""
FeatureLayerID = ""
SavePath= r""

if username == "" and password == "":
    gis = GIS()
else:
    gis = GIS(PortalUrl, username, password)
FeatureLayer = gis.content.get(FeatureLayerID)
layer = FeatureLayer.layers[0]
print(layer)
layer.attachments.download(save_path=SavePath)

################# Copy image #######################
for root, dirs, files in os.walk(SavePath):
    print(root, dirs, files)
    for f in files:
        if f.endswith('*'):
            print("Copy jpg: {0}".format(str(f)))
            pathOriginal = os.path.join(root,f)
            pathTarget = os.path.join(SavePath,f)
            shutil.copyfile(pathOriginal, pathTarget)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 13:53:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407111#M70275</guid>
      <dc:creator>PolzinFiona</dc:creator>
      <dc:date>2024-04-08T13:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: layer.attachments.download doesn't work for sublayers</title>
      <link>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407125#M70276</link>
      <description>&lt;P&gt;You should just have to change line 15 and specify the sublayer's index number.&amp;nbsp; For example, if it's the 3rd layer in the service it would be an index of 2:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;layer = FeatureLayer.layers[2]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 14:16:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407125#M70276</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-04-08T14:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: layer.attachments.download doesn't work for sublayers</title>
      <link>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407524#M70278</link>
      <description>&lt;P&gt;Thank you very much,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10527"&gt;@JakeSkinner&lt;/a&gt;.&amp;nbsp;&lt;BR /&gt;This is going in the right direction, however, upon further reflection, we realized that our initial inquiry was not quite aligned. Instead of accessing sublayers and their attachments, we need guidance on accessing related tables and their attachments within our Python code. Please excuse the confusion.&lt;/P&gt;&lt;P&gt;We've tried many queries but we seem to be stuck again. Do you know whether it's even possible to access&amp;nbsp; related tables or attachments in related tables?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2024 14:29:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407524#M70278</guid>
      <dc:creator>PolzinFiona</dc:creator>
      <dc:date>2024-04-09T14:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: layer.attachments.download doesn't work for sublayers</title>
      <link>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407572#M70279</link>
      <description>&lt;P&gt;Are you accessing a Feature Service?&amp;nbsp; I'm able to query the attachments with a Feature Service, but not a Map Service.&amp;nbsp; Ex:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;itemID = 'c820edb1d16c42b5a95fab40634417e8' # Feature Service
lyr = gis.content.get(itemID) 
lyr.tables[0].attachments.get_list() # relationship is with a table&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 09 Apr 2024 15:27:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1407572#M70279</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-04-09T15:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: layer.attachments.download doesn't work for sublayers</title>
      <link>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1413520#M70414</link>
      <description>&lt;P&gt;&amp;nbsp;Hi, thank you very much for your reply!&lt;/P&gt;&lt;P&gt;I was not in the office so I could not get back to you earlier. Please excuse the delayed answer!&lt;/P&gt;&lt;P&gt;Yes, we are accessing a feature service!&lt;/P&gt;&lt;P&gt;We tested your code and it works just fine on a simple point feature service with one related table. The feature service is branch versioned.&lt;/P&gt;&lt;P&gt;However, we applied the code on a feature service which has at least 15 related tables which each of may include an attachment. In that case, the code fails, unfortunately.&lt;/P&gt;&lt;P&gt;Just in case, I am providing a screenshot of the table properties:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PolzinFiona_0-1713796660633.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101692i43E3AB899C952382/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PolzinFiona_0-1713796660633.png" alt="PolzinFiona_0-1713796660633.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;....and a screenshot of the settings applied before publishing the feature service:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PolzinFiona_1-1713796695474.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101693i3F9B0BC42F479121/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PolzinFiona_1-1713796695474.png" alt="PolzinFiona_1-1713796695474.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Do you know whether there is a limitation regarding the number of related tables? Is it possible to use a code which looks up every single table related to one feature service to verify whether it has an attachment ? If it is possible, how is it possible to access it?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 14:42:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layer-attachments-download-doesn-t-work-for/m-p/1413520#M70414</guid>
      <dc:creator>PolzinFiona</dc:creator>
      <dc:date>2024-04-22T14:42:05Z</dc:date>
    </item>
  </channel>
</rss>

