<?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: Dropbox API v2 - Empty file on upload in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-API-v2-Empty-file-on-upload/m-p/392658#M21660</link>
    <description>&lt;P&gt;[Cross-linking for reference:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/59904691/laravel-dropbox-api-v2-empty-file-on-upload" target="_blank"&gt;https://stackoverflow.com/questions/59904691/laravel-dropbox-api-v2-empty-file-on-upload&lt;/A&gt;&amp;nbsp;]&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;Dropbox API&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload" target="_self"&gt;/2/files/upload&lt;/A&gt; endpoint is a &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#formats" target="_self"&gt;"content-upload" style endpoint&lt;/A&gt;, meaning that it expects the file data for the upload in the HTTPS request body. Exactly how you set the file data in the request body will depend on what HTTPS client you're using. The example included with &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload" target="_self"&gt;the documentation&lt;/A&gt; is written for curl on the command line, which uses curl's "data-binary" parameter to set the request body.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other HTTPS clients, such as Guzzle in your case, may use different option names. It sounds like you've already figured out the equivalent for Guzzle and got this working. I can't speak to whether or not there's a better option or method in Guzzle though, as that's made by a third party.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jan 2020 16:26:21 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2020-01-27T16:26:21Z</dc:date>
    <item>
      <title>Dropbox API v2 - Empty file on upload</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-API-v2-Empty-file-on-upload/m-p/392295#M21655</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;I use the dropbox v2 api to upload a file using laravel and guzzle.&lt;/P&gt;&lt;P&gt;However the file in dropbox shows empty. Those files have a sie of 0 bytes.&lt;/P&gt;&lt;P&gt;It have to do with my post call to the API because the file contents are still there before calling the upload call.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$client = new Client;

            $response = $client-&amp;gt;post("https://content.dropboxapi.com/2/files/upload", [
                'headers' =&amp;gt; [
                    'Authorization' =&amp;gt; 'Bearer '.$this-&amp;gt;getAccessToken(),
                    'Dropbox-API-Arg' =&amp;gt; json_encode([
                        'path' =&amp;gt; $path,
                        'mode' =&amp;gt; 'add',
                        'autorename' =&amp;gt; true,
                        'mute' =&amp;gt; true,
                        'strict_conflict' =&amp;gt; false
                    ]),
                    'Content-Type' =&amp;gt; 'application/octet-stream',
                    'data-binary' =&amp;gt; "@$file"
                ]
            ]);

            return json_decode($response-&amp;gt;getBody()-&amp;gt;getContents(), true);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;After some testing I made it work with using&lt;/P&gt;&lt;PRE&gt;'body' =&amp;gt; fopen($file, "r")&lt;/PRE&gt;&lt;P&gt;instead of&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;'data-binary' =&amp;gt; "@$file"&lt;/PRE&gt;&lt;P&gt;as described in the dropbox api v2 documentation.&lt;/P&gt;&lt;P&gt;Is there a better solution to this?&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jan 2020 00:37:33 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-API-v2-Empty-file-on-upload/m-p/392295#M21655</guid>
      <dc:creator>Ismaelw</dc:creator>
      <dc:date>2020-01-25T00:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dropbox API v2 - Empty file on upload</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-API-v2-Empty-file-on-upload/m-p/392658#M21660</link>
      <description>&lt;P&gt;[Cross-linking for reference:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/59904691/laravel-dropbox-api-v2-empty-file-on-upload" target="_blank"&gt;https://stackoverflow.com/questions/59904691/laravel-dropbox-api-v2-empty-file-on-upload&lt;/A&gt;&amp;nbsp;]&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;Dropbox API&amp;nbsp;&lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload" target="_self"&gt;/2/files/upload&lt;/A&gt; endpoint is a &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#formats" target="_self"&gt;"content-upload" style endpoint&lt;/A&gt;, meaning that it expects the file data for the upload in the HTTPS request body. Exactly how you set the file data in the request body will depend on what HTTPS client you're using. The example included with &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload" target="_self"&gt;the documentation&lt;/A&gt; is written for curl on the command line, which uses curl's "data-binary" parameter to set the request body.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other HTTPS clients, such as Guzzle in your case, may use different option names. It sounds like you've already figured out the equivalent for Guzzle and got this working. I can't speak to whether or not there's a better option or method in Guzzle though, as that's made by a third party.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 16:26:21 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Dropbox-API-v2-Empty-file-on-upload/m-p/392658#M21660</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-01-27T16:26:21Z</dc:date>
    </item>
  </channel>
</rss>

