<?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>question How would you download (copy) a directory with WebHDFS API? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99538#M12718</link>
    <description>&lt;P&gt;I'm looking at &lt;A href="https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#File_and_Directory_Operations"&gt;https://hadoop.apache.org/docs/current/hadoop-proj...&lt;/A&gt; and I don't find an easy way to copy one folder.&lt;/P&gt;&lt;P&gt;Do I have to get the list of the content of the folder and download one by one?&lt;/P&gt;</description>
    <pubDate>Wed, 16 Dec 2015 18:01:07 GMT</pubDate>
    <dc:creator>hosako</dc:creator>
    <dc:date>2015-12-16T18:01:07Z</dc:date>
    <item>
      <title>How would you download (copy) a directory with WebHDFS API?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99538#M12718</link>
      <description>&lt;P&gt;I'm looking at &lt;A href="https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#File_and_Directory_Operations"&gt;https://hadoop.apache.org/docs/current/hadoop-proj...&lt;/A&gt; and I don't find an easy way to copy one folder.&lt;/P&gt;&lt;P&gt;Do I have to get the list of the content of the folder and download one by one?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 18:01:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99538#M12718</guid>
      <dc:creator>hosako</dc:creator>
      <dc:date>2015-12-16T18:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: How would you download (copy) a directory with WebHDFS API?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99539#M12719</link>
      <description>&lt;P&gt;add "recursive" switch &lt;/P&gt;&lt;PRE&gt;curl -i -X DELETE "http://&amp;lt;host&amp;gt;:&amp;lt;port&amp;gt;/webhdfs/v1/&amp;lt;path&amp;gt;?op=DELETE
                              [&amp;amp;recursive=&amp;lt;true |false&amp;gt;]"&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Dec 2015 21:25:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99539#M12719</guid>
      <dc:creator>aervits</dc:creator>
      <dc:date>2015-12-16T21:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: How would you download (copy) a directory with WebHDFS API?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99540#M12720</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/393/aervits.html" nodeid="393"&gt;@Artem Ervits&lt;/A&gt; Looks like he is asking for way to copy the contents of whole directory rather than deleting it.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 21:33:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99540#M12720</guid>
      <dc:creator>pardeep_kumar</dc:creator>
      <dc:date>2015-12-16T21:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: How would you download (copy) a directory with WebHDFS API?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99541#M12721</link>
      <description>&lt;P&gt;I'm aware of that, this was the only available example. Just add a recursive switch=true to the command you want to execute.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 21:42:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99541#M12721</guid>
      <dc:creator>aervits</dc:creator>
      <dc:date>2015-12-16T21:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: How would you download (copy) a directory with WebHDFS API?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99542#M12722</link>
      <description>&lt;P&gt;Downloading an entire directory would be a recursive operation that walks the entire sub-tree, downloading each file it encounters in that sub-tree.  The WebHDFS REST API alone doesn't implement any such recursive operations.  (The recursive=true option for DELETE is a different case, because it's just telling the NameNode to prune the whole sub-tree.  There isn't any need to traverse the sub-tree and return results to the caller along the way.)  Recursion is something that would have to be implemented on the client side by listing the contents of a directory, and then handling the children returned for that directory.&lt;/P&gt;&lt;P&gt;Depending on what you need to do, it might be sufficient to use the "hdfs dfs -copyToLocal" CLI command using a path with the "webhdfs" URI scheme and a wildcard.  Here is an example:&lt;/P&gt;&lt;PRE&gt;&amp;gt; hdfs dfs -ls webhdfs://localhost:50070/file*
-rw-r--r--   3 chris supergroup          6 2015-12-15 10:13 webhdfs://localhost:50070/file1
-rw-r--r--   3 chris supergroup          6 2015-12-15 10:13 webhdfs://localhost:50070/file2

&amp;gt; hdfs dfs -copyToLocal webhdfs://localhost:50070/file*

&amp;gt; ls -lrt file*
-rw-r--r--+ 1 chris  staff     6B Dec 16 10:23 file2
-rw-r--r--+ 1 chris  staff     6B Dec 16 10:23 file1
&lt;/PRE&gt;&lt;P&gt;In this example, the "hdfs dfs -copyToLocal" command made a WebHDFS HTTP call to the NameNode to list the contents of "/".  It then filtered the returned results by the glob pattern "file*".  Based on those filtered results, it then sent a series of additional HTTP calls to the NameNode and DataNodes to get the contents of file1 and file2 and write them locally.&lt;/P&gt;&lt;P&gt;This isn't a recursive solution though.  Wildcard glob matching is only sufficient for matching a static pattern and walking to a specific depth in the tree.  It can't fully discover and walk the whole sub-tree.  That would require custom application code.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 02:32:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99542#M12722</guid>
      <dc:creator>cnauroth</dc:creator>
      <dc:date>2015-12-17T02:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: How would you download (copy) a directory with WebHDFS API?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99543#M12723</link>
      <description>&lt;P&gt;Thank you! I will play with it.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 06:21:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-would-you-download-copy-a-directory-with-WebHDFS-API/m-p/99543#M12723</guid>
      <dc:creator>hosako</dc:creator>
      <dc:date>2015-12-17T06:21:38Z</dc:date>
    </item>
  </channel>
</rss>

