<?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: Get size without authenticating? in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-size-without-authenticating/m-p/326#M21</link>
    <description>&lt;P&gt;Thanks. That works, however, I had to use "curl -LI", otherwise it tries to download the entire file. And it worked fine with the original "dl=0" link as well.&lt;/P&gt;</description>
    <pubDate>Sun, 07 Dec 2014 04:25:58 GMT</pubDate>
    <dc:creator>Ze'ev G.</dc:creator>
    <dc:date>2014-12-07T04:25:58Z</dc:date>
    <item>
      <title>Get size without authenticating?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-size-without-authenticating/m-p/324#M19</link>
      <description>&lt;P&gt;Can I get the size of a file via a CURL command given only a link without authenticating?&lt;BR /&gt;
E.g., &lt;BR /&gt;
&lt;A href="https://www.dropbox.com/s/uf12345szlap449/Files.mp4?dl=0" rel="nofollow noreferrer" target="_blank"&gt;https://www.dropbox.com/s/uf12345szlap449/Files.mp4?dl=0&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:47:08 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-size-without-authenticating/m-p/324#M19</guid>
      <dc:creator>Ze'ev G.</dc:creator>
      <dc:date>2019-05-29T09:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get size without authenticating?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-size-without-authenticating/m-p/325#M20</link>
      <description>&lt;P&gt;Shared links like this (generally) don't require you to authenticate to access the content, so you can get the content and check the length. For example, using this link:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?dl=0" rel="nofollow noreferrer"&gt;https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?dl=0&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;We can ask for the raw file content by modifying the parameters as shown here:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.dropbox.com/help/201" rel="nofollow noreferrer"&gt;https://www.dropbox.com/help/201&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;This gives us this version of the link:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?raw=1" rel="nofollow noreferrer"&gt;https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?raw=1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;We can then access the content programmatically, e.g., using curl:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;curl -L &lt;A href="https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?raw=1" rel="nofollow noreferrer"&gt;https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?raw=1&lt;/A&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;(The -L is necessary to follow redirects.)&lt;/P&gt;

&lt;P&gt;The response contains the length in the "Content-Length" header, e.g.:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Content-Length: 14&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Alternatively, you can check the length of the returned file yourself.&lt;/P&gt;

&lt;P&gt;Or, here's a more advanced method, using the Python requests library, to get the Content-Length without downloading the file, by using a HEAD request:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import requests

url = "https://www.dropbox.com/s/vv7us05r9z46lwt/hello_world.txt?raw=1"

redirected_url = requests.head(url).headers['location']

content_length = requests.head(redirected_url).headers['Content-Length']

print content_length
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Just don't re-use redirected_url. Always get a new one from the original link.)&lt;/P&gt;</description>
      <pubDate>Sat, 06 Dec 2014 09:20:27 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-size-without-authenticating/m-p/325#M20</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2014-12-06T09:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Get size without authenticating?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-size-without-authenticating/m-p/326#M21</link>
      <description>&lt;P&gt;Thanks. That works, however, I had to use "curl -LI", otherwise it tries to download the entire file. And it worked fine with the original "dl=0" link as well.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Dec 2014 04:25:58 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-size-without-authenticating/m-p/326#M21</guid>
      <dc:creator>Ze'ev G.</dc:creator>
      <dc:date>2014-12-07T04:25:58Z</dc:date>
    </item>
  </channel>
</rss>

