<?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: Downloading a file from a shared folder PHP CURL in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-file-from-a-shared-folder-PHP-CURL/m-p/481683#M24286</link>
    <description>&lt;P&gt;It looks like the file isn't being found because the API call doesn't have the correct root. That is, it seems like this file is in your team space, but by default API calls operate in the team member folder, not the team space. You can configure calls to access the team space though, by setting the 'Dropbox-API-Path-Root' header. Please read &lt;A href="https://www.dropbox.com/lp/developers/reference/dbx-team-files-guide" target="_self"&gt;the Team Files Guide&lt;/A&gt; for information on using this functionality.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Dec 2020 22:06:27 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2020-12-23T22:06:27Z</dc:date>
    <item>
      <title>Downloading a file from a shared folder PHP CURL</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-file-from-a-shared-folder-PHP-CURL/m-p/481625#M24284</link>
      <description>&lt;P&gt;I have a business account and we have files in a shared folder. I currently can list of files within folder and this is an example of response I get&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; #items: array:500 [▼
    0 =&amp;gt; array:12 [▼
      ".tag" =&amp;gt; "file"
      "name" =&amp;gt; "file.mp4"
      "parent_shared_folder_id" =&amp;gt; "8693457712"
      "id" =&amp;gt; "id:6_UMBoPQ5zAAAAAAAAAqcQ"
      "client_modified" =&amp;gt; "2020-04-26T00:17:02Z"
      "server_modified" =&amp;gt; "2020-11-19T14:20:38Z"
      "rev" =&amp;gt; "015b4766e9661ac00000002062ba330"
      "size" =&amp;gt; 1952676954
      "sharing_info" =&amp;gt; array:3 [ …3]
      "is_downloadable" =&amp;gt; true
      "has_explicit_shared_members" =&amp;gt; false
      "content_hash" =&amp;gt; "4e9217a7937cfae02cdb41d4baf9b1126f555729ee2a38a0b82d9d27ac320bae"
    ]&lt;/PRE&gt;
&lt;P&gt;Now, everytime I try to download the file from dropbox to a local path I get folder not found.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using function below:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  function dbx_get_file($token, $in_filepath, $out_filepath)
    {
        $out_fp = fopen($out_filepath, 'w+');
        if ($out_fp === FALSE)
            {
            echo "fopen error; can't open $out_filepath\n";
            return (NULL);
            }

        $url = 'https://content.dropboxapi.com/2/files/download';

        $header_array = array(
            'Authorization: Bearer ' . $token,
            'Content-Type:',
            'Dropbox-API-Arg: {"path":"' . $in_filepath . '"}',
            'Dropbox-Api-Select-User: dbmid:ffffffffff-fhfdjkfhkjfdshkj'

        );

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header_array);
        curl_setopt($ch, CURLOPT_FILE, $out_fp);

        

        $metadata = null;
        curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $header) use (&amp;amp;$metadata)
            {
            $prefix = 'dropbox-api-result:';
            if (strtolower(substr($header, 0, strlen($prefix))) === $prefix)
                {
                $metadata = json_decode(substr($header, strlen($prefix)), true);
                }
            return strlen($header);
            }
        );

        $output = curl_exec($ch);

        if ($output === FALSE)
            {
            echo "curl error: " . curl_error($ch);
            }

        curl_close($ch);
        fclose($out_fp);

        return($metadata);
    } 
    &lt;/PRE&gt;
&lt;P&gt;Now issue is path.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming my folder name is "My Company", what would be the path? I've tried below patterns&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;foldername/filename&lt;/LI&gt;
&lt;LI&gt;parent_shared_folder_id/filename&lt;/LI&gt;
&lt;LI&gt;parent_shared_folder_id/file id&lt;/LI&gt;
&lt;LI&gt;/&lt;/LI&gt;
&lt;LI&gt;null&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;And I keep getting path not found. Has anyone having the same issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2020 17:41:49 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-file-from-a-shared-folder-PHP-CURL/m-p/481625#M24284</guid>
      <dc:creator>rasbox</dc:creator>
      <dc:date>2020-12-23T17:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: Downloading a file from a shared folder PHP CURL</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-file-from-a-shared-folder-PHP-CURL/m-p/481683#M24286</link>
      <description>&lt;P&gt;It looks like the file isn't being found because the API call doesn't have the correct root. That is, it seems like this file is in your team space, but by default API calls operate in the team member folder, not the team space. You can configure calls to access the team space though, by setting the 'Dropbox-API-Path-Root' header. Please read &lt;A href="https://www.dropbox.com/lp/developers/reference/dbx-team-files-guide" target="_self"&gt;the Team Files Guide&lt;/A&gt; for information on using this functionality.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2020 22:06:27 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-file-from-a-shared-folder-PHP-CURL/m-p/481683#M24286</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-12-23T22:06:27Z</dc:date>
    </item>
  </channel>
</rss>

