<?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: question about response from download method in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186780#M7933</link>
    <description>&lt;P&gt;Ok, sorry I'm being dense. Given the code I posted, how do I retrieve the Dropbox-API-Result header?&lt;/P&gt;</description>
    <pubDate>Wed, 31 Aug 2016 07:00:10 GMT</pubDate>
    <dc:creator>Barry L.12</dc:creator>
    <dc:date>2016-08-31T07:00:10Z</dc:date>
    <item>
      <title>question about response from download method</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186776#M7929</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm studying the documentation for the files /download method in both the API Explorer:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://dropbox.github.io/dropbox-api-v2-explorer/#files_download" rel="nofollow noreferrer" target="_blank"&gt;https://dropbox.github.io/dropbox-api-v2-explorer/#files_download&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;And in the developer documentation area:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-download" rel="nofollow noreferrer" target="_blank"&gt;https://www.dropbox.com/developers/documentation/http/documentation#files-download&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In both cases/places the documentation indicates that a data structure is returned, showing the meta-data of the item to be downloaded. But where is it documented where and how the actual data of the item -- the file contents -- is obtained?&lt;/P&gt;
&lt;P&gt;Meanwhile, in my test program, I'm finding that the "return value" of the call to /download is, in fact, the file contents, and if I write that data to a file in the local file system, I get a valid file (in this case a jpg photo that's viewable in any app that displays image data). But where, then, do I obtain the meta-data about the photo that the documentation says is returned?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Barry&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:30:25 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186776#M7929</guid>
      <dc:creator>Barry L.12</dc:creator>
      <dc:date>2019-05-29T09:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: question about response from download method</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186777#M7930</link>
      <description>&lt;P&gt;Take a look at the "Request and response formats" section at&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation" rel="nofollow noreferrer"&gt;https://www.dropbox.com/developers/documentation/http/documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;In particular:&lt;/P&gt;
&lt;H4&gt;Content-download endpoints&lt;/H4&gt;
&lt;P&gt;As with content-upload endpoints, arguments are passed in the &lt;CODE&gt;Dropbox-API-Arg&lt;/CODE&gt; request header or &lt;CODE&gt;arg&lt;/CODE&gt; URL parameter. The response body contains file content, so the result will appear as JSON in the &lt;CODE&gt;Dropbox-API-Result&lt;/CODE&gt; response header. These endpoints are also on the&lt;CODE&gt;content.dropboxapi.com&lt;/CODE&gt; domain.&lt;/P&gt;
&lt;P&gt;These endpoints also support HTTP GET along with &lt;CODE&gt;ETag&lt;/CODE&gt;-based caching (&lt;CODE&gt;If-None-Match&lt;/CODE&gt;) and HTTP range requests.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 06:25:33 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186777#M7930</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2016-08-31T06:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: question about response from download method</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186778#M7931</link>
      <description>&lt;P&gt;I really appreciate the response. Unfortunately, I don't understand it.&lt;/P&gt;
&lt;P&gt;The origin of the problem is that Dropbox has dropped support for PHP. I had this all working in API v1. In order to use API v2 I've "rolled my own". If you're willing to look at some code, here is my simple PHP function to retrieve a file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;function dbx_get_file($token, $in_filepath, $out_filepath)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp; $out_fp = fopen($out_filepath, 'w+');&lt;BR /&gt;&amp;nbsp; if ($out_fp === FALSE)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo "fopen error; can't open $out_filepath\n";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (NULL);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; $url = '&lt;A href="https://content.dropboxapi.com/2/files/download" rel="nofollow noreferrer"&gt;https://content.dropboxapi.com/2/files/download&lt;/A&gt;';&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; $header_array = array(&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Authorization: Bearer ' . $token,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Content-Type:',&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Dropbox-API-Arg: {"path":"' . $in_filepath . '"}'&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; $ch = curl_init();&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; curl_setopt($ch, CURLOPT_URL, $url);&lt;BR /&gt;&amp;nbsp; curl_setopt($ch, CURLOPT_POST, TRUE);&lt;BR /&gt;&amp;nbsp; curl_setopt($ch, CURLOPT_HTTPHEADER, $header_array);&lt;BR /&gt;&amp;nbsp; curl_setopt($ch, CURLOPT_FILE, $out_fp);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; $output_array = array();&lt;BR /&gt;&amp;nbsp; $output = curl_exec($ch);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; if ($output === FALSE)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo "curl error: " . curl_error($ch);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $output_array = json_decode($output, TRUE);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; curl_close($ch);&lt;BR /&gt;&amp;nbsp; fclose($out_fp);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; return($output_array);&lt;BR /&gt;&amp;nbsp; }&amp;nbsp; // dbx_get_file()&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I said, this function returns the contents of the requested file. Where, then, is the meta-data?&lt;/P&gt;
&lt;P&gt;Thanks, and sorry if I'm missing something obvious.&lt;/P&gt;
&lt;P&gt;Barry&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 06:37:44 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186778#M7931</guid>
      <dc:creator>Barry L.12</dc:creator>
      <dc:date>2016-08-31T06:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: question about response from download method</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186779#M7932</link>
      <description>&lt;P&gt;The metadata is in the&amp;nbsp;Dropbox-API-Result&amp;nbsp;header of the response.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 06:58:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186779#M7932</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2016-08-31T06:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: question about response from download method</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186780#M7933</link>
      <description>&lt;P&gt;Ok, sorry I'm being dense. Given the code I posted, how do I retrieve the Dropbox-API-Result header?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 07:00:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186780#M7933</guid>
      <dc:creator>Barry L.12</dc:creator>
      <dc:date>2016-08-31T07:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: question about response from download method</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186781#M7934</link>
      <description>&lt;P&gt;You're not being dense... this is extremely hard to do with&amp;nbsp;curl in PHP. Here's some working code:&lt;/P&gt;
&lt;PRE&gt;function dbx_get_file($token, $in_filepath, $out_filepath)&lt;BR /&gt;    {&lt;BR /&gt;    $out_fp = fopen($out_filepath, 'w+');&lt;BR /&gt;    if ($out_fp === FALSE)&lt;BR /&gt;        {&lt;BR /&gt;        echo "fopen error; can't open $out_filepath\n";&lt;BR /&gt;        return (NULL);&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;    $url = 'https://content.dropboxapi.com/2/files/download';&lt;BR /&gt;&lt;BR /&gt;    $header_array = array(&lt;BR /&gt;        'Authorization: Bearer ' . $token,&lt;BR /&gt;        'Content-Type:',&lt;BR /&gt;        'Dropbox-API-Arg: {"path":"' . $in_filepath . '"}'&lt;BR /&gt;    );&lt;BR /&gt;&lt;BR /&gt;    $ch = curl_init();&lt;BR /&gt;&lt;BR /&gt;    curl_setopt($ch, CURLOPT_URL, $url);&lt;BR /&gt;    curl_setopt($ch, CURLOPT_POST, TRUE);&lt;BR /&gt;    curl_setopt($ch, CURLOPT_HTTPHEADER, $header_array);&lt;BR /&gt;    curl_setopt($ch, CURLOPT_FILE, $out_fp);&lt;BR /&gt;&lt;BR /&gt;    $metadata = null;&lt;BR /&gt;    curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $header) use (&amp;amp;$metadata)&lt;BR /&gt;        {&lt;BR /&gt;        $prefix = 'dropbox-api-result:';&lt;BR /&gt;        if (strtolower(substr($header, 0, strlen($prefix))) === $prefix)&lt;BR /&gt;            {&lt;BR /&gt;            $metadata = json_decode(substr($header, strlen($prefix)), true);&lt;BR /&gt;            }&lt;BR /&gt;        return strlen($header);&lt;BR /&gt;        }&lt;BR /&gt;    );&lt;BR /&gt;&lt;BR /&gt;    $output = curl_exec($ch);&lt;BR /&gt;&lt;BR /&gt;    if ($output === FALSE)&lt;BR /&gt;        {&lt;BR /&gt;        echo "curl error: " . curl_error($ch);&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;    curl_close($ch);&lt;BR /&gt;    fclose($out_fp);&lt;BR /&gt;&lt;BR /&gt;    return($metadata);&lt;BR /&gt;    } // dbx_get_file()&lt;BR /&gt;&lt;BR /&gt;$metadata = dbx_get_file("&amp;lt;REDACTED&amp;gt;", '/test.txt', 'test.txt');&lt;BR /&gt;echo "File " . $metadata['name'] . " has the rev " . $metadata['rev'] . ".\n";&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 08:27:06 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186781#M7934</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2016-08-31T08:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: question about response from download method</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186782#M7935</link>
      <description>&lt;P&gt;Compare to the much saner &lt;A href="https://github.com/rmccue/Requests" target="_blank" rel="nofollow noreferrer"&gt;Requests library&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;$response = Requests::post("https://content.dropboxapi.com/2/files/download", array(&lt;BR /&gt;    'Authorization' =&amp;gt; "Bearer $token",&lt;BR /&gt;    'Dropbox-Api-Arg' =&amp;gt; json_encode(array('path' =&amp;gt; '/test.txt')),&lt;BR /&gt;));&lt;BR /&gt;&lt;BR /&gt;$fileContent = $response-&amp;gt;body;&lt;BR /&gt;$metadata = json_decode($response-&amp;gt;headers['Dropbox-Api-Result'], true);&lt;BR /&gt;&lt;BR /&gt;echo "File " . $metadata["name"] . " has the rev " . $metadata["rev"] . ".\n";&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Aug 2016 08:31:49 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186782#M7935</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2016-08-31T08:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: question about response from download method</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186783#M7936</link>
      <description>&lt;P&gt;Wow, thanks! You, sir, are a star. This is the first I've heard of the Requests library. You can bet I'll be spending some time studying it. 
&lt;BR /&gt;It's interesting to note that both of the Dropbox API v2 PHP libraries provided by community developers are based on curl, and both are insanely complex. I wonder if they could be improved by using the Requests library...
&lt;BR /&gt;Anyway, thanks again.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 11:40:10 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186783#M7936</guid>
      <dc:creator>Barry L.12</dc:creator>
      <dc:date>2016-08-31T11:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: question about response from download method</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186784#M7937</link>
      <description>&lt;P&gt;Just in case any other Perl users come across this here is how to get it in Perl (using &lt;A href="https://metacpan.org/pod/LWP::UserAgent" target="_blank" rel="nofollow noreferrer"&gt;LWP::UserAgent&lt;/A&gt;, &lt;A href="https://metacpan.org/pod/HTTP::Request" target="_blank" rel="nofollow noreferrer"&gt;HTTP::Request&lt;/A&gt;, &lt;A href="https://metacpan.org/pod/HTTP::Headers" target="_blank" rel="nofollow noreferrer"&gt;HTTP::Headers&lt;/A&gt; and &lt;A href="https://metacpan.org/pod/JSON" target="_blank" rel="nofollow noreferrer"&gt;JSON&lt;/A&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@B0F70D28791EB05FA3EA0C3BDDF08EE3/emoticons/1f61e.png" alt=":disappointed_face:" title=":disappointed_face:" /&gt;&lt;/P&gt;
&lt;P&gt;my $response = $ua-&amp;gt;request($request);&amp;nbsp; &lt;BR /&gt;my $file_contents = $response-&amp;gt;content;&lt;BR /&gt;my $json = decode_json($response-&amp;gt;header("Dropbox-Api-Result"));&lt;BR /&gt;my $filename = $json-&amp;gt;{name};&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2016 02:20:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/question-about-response-from-download-method/m-p/186784#M7937</guid>
      <dc:creator>Daniel S.33</dc:creator>
      <dc:date>2016-09-08T02:20:13Z</dc:date>
    </item>
  </channel>
</rss>

