<?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 Weird behaviour when using item.get_data() with PDF files in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799283#M1985</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I'm trying to use the &lt;STRONG&gt;item.get_data()&lt;/STRONG&gt; method in a backup tool, to download all files from my content. However, when I call this method and the &lt;STRONG&gt;item.type&lt;/STRONG&gt; is &lt;STRONG&gt;PDF&lt;/STRONG&gt;, instead giving me the local path where the PDF should be stored, it gives me somthig like this: &lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;b'PK\x03\x04\x14\x00\x06\x00\x08\x00\x00\x00!\x00\xa0\x82\x90\x90\xc5\x01\x00\x00\xe2\x08\x00\x00\x13\x00\x08\x02[Content_Types].xml \xa2\x04\x02(\xa0\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0 ....'&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Is this the normal behaviour? When calling this method with CSV, KML, etc it works as I expected. The whole code I'm using is here: &lt;A class="link-titled" href="https://github.com/aitorcalero/GISBox/blob/BackupTool/ArcGISBackup.py" title="https://github.com/aitorcalero/GISBox/blob/BackupTool/ArcGISBackup.py"&gt;GISBox/ArcGISBackup.py at BackupTool · aitorcalero/GISBox · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part of the problem could be that I use this:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;path = str(item.get_data())&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;to convert it to a string. However, if it's that the case, how do I get the path to the dowloaded PDF? The item.get_data() method when used in a PDF seems to be returning a {byte} array.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 27 Aug 2017 18:45:34 GMT</pubDate>
    <dc:creator>AitorCalero_García</dc:creator>
    <dc:date>2017-08-27T18:45:34Z</dc:date>
    <item>
      <title>Weird behaviour when using item.get_data() with PDF files</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799283#M1985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I'm trying to use the &lt;STRONG&gt;item.get_data()&lt;/STRONG&gt; method in a backup tool, to download all files from my content. However, when I call this method and the &lt;STRONG&gt;item.type&lt;/STRONG&gt; is &lt;STRONG&gt;PDF&lt;/STRONG&gt;, instead giving me the local path where the PDF should be stored, it gives me somthig like this: &lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;b'PK\x03\x04\x14\x00\x06\x00\x08\x00\x00\x00!\x00\xa0\x82\x90\x90\xc5\x01\x00\x00\xe2\x08\x00\x00\x13\x00\x08\x02[Content_Types].xml \xa2\x04\x02(\xa0\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0 ....'&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Is this the normal behaviour? When calling this method with CSV, KML, etc it works as I expected. The whole code I'm using is here: &lt;A class="link-titled" href="https://github.com/aitorcalero/GISBox/blob/BackupTool/ArcGISBackup.py" title="https://github.com/aitorcalero/GISBox/blob/BackupTool/ArcGISBackup.py"&gt;GISBox/ArcGISBackup.py at BackupTool · aitorcalero/GISBox · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part of the problem could be that I use this:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;path = str(item.get_data())&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;to convert it to a string. However, if it's that the case, how do I get the path to the dowloaded PDF? The item.get_data() method when used in a PDF seems to be returning a {byte} array.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Aug 2017 18:45:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799283#M1985</guid>
      <dc:creator>AitorCalero_García</dc:creator>
      <dc:date>2017-08-27T18:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Weird behaviour when using item.get_data() with PDF files</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799284#M1986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Aitor,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested your problem, beeing conected to my ArcGIS Online Dev account, with a .pdf item and I can confirm that same problem happens. Also, I tried to dump it as json or to decode using utf-8 (as said in the methodology : &lt;A class="link-titled" href="http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html?highlight=get_data#arcgis.gis.Item.get_data" title="http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html?highlight=get_data#arcgis.gis.Item.get_data"&gt;arcgis.gis module — arcgis 1.2.1 documentation&lt;/A&gt;&amp;nbsp;&amp;nbsp;) but no result, same problem... &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp;I`m also looking forward for a solution to this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ionut&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2017 09:23:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799284#M1986</guid>
      <dc:creator>IonutAlixandroae4</dc:creator>
      <dc:date>2017-08-28T09:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Weird behaviour when using item.get_data() with PDF files</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799285#M1987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To download a pdf file, try using `&lt;STRONG&gt;Item.download()&lt;/STRONG&gt;` method. The `&lt;STRONG&gt;get_data()&lt;/STRONG&gt;` is intended to read text based files such as JSON, CSV, XML.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: These two methods were enhanced in version 1.2. If you are using an older build, please update to the latest &lt;STRONG&gt;1.2.1&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2017 16:36:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799285#M1987</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-08-28T16:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Weird behaviour when using item.get_data() with PDF files</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799286#M1988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Atma! It worked like a charm. By the way, is there any way to get the file extension of a file stored in ArcGIS Onine in the Python API? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2017 19:24:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799286#M1988</guid>
      <dc:creator>AitorCalero_García</dc:creator>
      <dc:date>2017-08-28T19:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Weird behaviour when using item.get_data() with PDF files</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799287#M1989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am assuming the reason you want to know the extension is to decide whether to use&amp;nbsp;&lt;STRONG&gt;download()&amp;nbsp;&lt;/STRONG&gt;or&amp;nbsp;&lt;STRONG&gt;get_data()&lt;/STRONG&gt;. While there is no property or method, you can use&amp;nbsp;&lt;STRONG&gt;download()&lt;/STRONG&gt; to always download any type of file (be it binary files like service definition, pdf or text based files like csv, webmap json etc).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In addition, you can use &lt;STRONG&gt;type and typeKeywords&amp;nbsp;&lt;/STRONG&gt;properties of the&amp;nbsp;&lt;STRONG&gt;Item&amp;nbsp;&lt;/STRONG&gt;object to get a sense of the item type and choose accordingly. In certain cases, you get extension as part of the&amp;nbsp;&lt;STRONG&gt;typeKeywords&lt;/STRONG&gt; list.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Aug 2017 19:50:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799287#M1989</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-08-28T19:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Weird behaviour when using item.get_data() with PDF files</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799288#M1990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Atma. The reason why I'm trying to get the extension is because &lt;STRONG&gt;I want to create a kind of back-up process replicating locally the folder structure&lt;/STRONG&gt; of a given account in ArcGIS Online/Enterprise. &lt;/P&gt;&lt;P&gt;I've tried to explore the type and typeKeywords options but the results are inconsistent. As you can see in the screenshots attached,&lt;STRONG&gt; these properties do not always return the same thing or even in the same position in the list and with ZIP items, you only get "ArcGIS Desktop"&lt;/STRONG&gt;. The only way I can get the extension seems to be to parse the path returned from the download() method.&lt;/P&gt;&lt;P&gt;That would be a new property to add in future releases of the API maybe.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Screenshots:&lt;/P&gt;&lt;P&gt;.&lt;IMG alt="Debug screen capture" class="image-1 jive-image j-img-original" src="/legacyfs/online/368984_ScreenClip [1].png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Debug screen capture 2" class="image-2 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/368985_ScreenClip.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Aug 2017 08:07:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/weird-behaviour-when-using-item-get-data-with-pdf/m-p/799288#M1990</guid>
      <dc:creator>AitorCalero_García</dc:creator>
      <dc:date>2017-08-29T08:07:19Z</dc:date>
    </item>
  </channel>
</rss>

