<?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: How to upload file via Curl with Binary object input? in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/609346#M2769</link>
    <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1556562"&gt;@karanag&lt;/a&gt; In your code, you're sending the data in your 'content' variable, which just contains the string '"@" + imagePath', not the actual file data at that path. In the examples in &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation" target="_blank"&gt;the Dropbox API documentation&lt;/A&gt;, the "@" is a way of telling curl on the command line to read from the local filesystem at that path. That wouldn't necessarily work in other environments, such as using XMLHttpRequest like you are here. You'll need to update your code to pass in the actual file data. Please refer to the documentation for your platform for information on accessing file data.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jul 2022 15:58:22 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2022-07-13T15:58:22Z</dc:date>
    <item>
      <title>How to upload file via Curl with Binary object input?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/605632#M2739</link>
      <description>&lt;P&gt;Hello, good evening for all. I would like to know, how I can to upload file using a Curl request, or PHP Curl request, with the &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload" target="_self"&gt;upload file request.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;But instead I use the parameter o filepath, I use the binary object inside body request, for example, some 010101101011010101010 binary code inside request instead of "/folder/filename.extension" . Because I am building a system client-server that a user can upload a file, sending by Post request to server, and the server must to take this file via $_ENV[] and insert it into a request to upload to Dropbox. And doesnt a way to server save temporary file inside your filesystem because the your provider is ephemeral, and so, because it i have to insert the file binary data inside request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will be grateful.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 21:17:46 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/605632#M2739</guid>
      <dc:creator>Amicao</dc:creator>
      <dc:date>2022-06-27T21:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload file via Curl with Binary object input?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/605852#M2741</link>
      <description>&lt;P&gt;[Cross-linking for reference: &lt;A href="https://stackoverflow.com/questions/72758417/how-to-upload-file-using-an-array-with-binary-data-file-object-to-dropbox-usin" target="_blank"&gt;https://stackoverflow.com/questions/72758417/how-to-upload-file-using-an-array-with-binary-data-file-object-to-dropbox-usin&lt;/A&gt; ]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When uploading a file to Dropbox using the Dropbox API /2/files/upload endpoint, the app needs to supply several different types of things, including:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the parameters for the upload call, &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload" target="_blank"&gt;documented&lt;/A&gt; under "UploadArg" and sent in the "Dropbox-API-Arg" request header: this includes a "path" parameter that tells Dropbox where Dropbox account you want to put the uploaded file. Refer to the documentation for your network client for information on how to set request headers.&lt;/LI&gt;
&lt;LI&gt;the bytes of the file data to upload, sent in the request body: this should be the exact file contents that you want to put in the connected Dropbox account at the path specified as noted above. Exactly how you retrieve the file data and put it in the request body will depend on the specific of your scenario. Refer to the documentation for your network client for information on how to set the request body.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;For example, using curl on the command line, this would upload a file to the remote path "/test_605632.txt" in Dropbox, telling curl to send the contents of the local file at the local (relative) path "test/test.txt" (the "@" is a way of telling curl to read from the local filesystem):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;curl -X POST https://content.dropboxapi.com/2/files/upload \
    --header "Authorization: Bearer &amp;lt;ACCESS_TOKEN&amp;gt;" \
    --header "Dropbox-API-Arg: {\"path\":\"/test_605632.txt\"}" \
    --header "Content-Type: application/octet-stream" \
    --data-binary &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/61275"&gt;@test&lt;/a&gt;/test.txt&lt;/LI-CODE&gt;
&lt;P&gt;And for comparison, this would upload a file to the remote path "/test_605632.txt" in Dropbox, telling curl to send the data "some data" itself (not from a local file):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;curl -X POST https://content.dropboxapi.com/2/files/upload \
    --header "Authorization: Bearer &amp;lt;ACCESS_TOKEN&amp;gt;" \
    --header "Dropbox-API-Arg: {\"path\":\"/test_605632.txt\"}" \
    --header "Content-Type: application/octet-stream" \
    --data-binary "some data"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 15:15:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/605852#M2741</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-06-27T15:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload file via Curl with Binary object input?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/609250#M2768</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am facing kind of the same problem. My Code is below but it uploading a corrupted image, any ideas what exactly I am doing wrong? I am trying to build my app using no-code tool AppGyver&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; imagePath = inputs.imagePath;&amp;nbsp; // (This line takes the path of the image)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; path = &lt;/SPAN&gt;&lt;SPAN&gt;"/Pictures/testPicturreABC12345.jpg"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; content = &lt;/SPAN&gt;&lt;SPAN&gt;"@"&lt;/SPAN&gt;&lt;SPAN&gt; + imagePath;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; accessToken = &lt;/SPAN&gt;&lt;SPAN&gt;"sl.BLX6BjKTDsrOpArs74Bk32Pg09Ukns0u3YUCsDnoagiOJdx2hq6iCZezCKlWc-53v8E6IVOaU3Tu0OAOGMrxc5KIVeihAn51f5hZ0x3EKpCJdEKuykWIz4SAeC4WcjXpKiSrhWC8"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; uploadUrl = &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;A href="https://content.dropboxapi.com/2/files/upload" target="_blank"&gt;https://content.dropboxapi.com/2/files/upload&lt;/A&gt;"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; result;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; xhr = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;XMLHttpRequest&lt;/SPAN&gt;&lt;SPAN&gt;();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;xhr.onreadystatechange = &lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt;() {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (xhr.readyState === &lt;/SPAN&gt;&lt;SPAN&gt;4&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;result = xhr.responseText;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; result;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;};&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;xhr.open(&lt;/SPAN&gt;&lt;SPAN&gt;"POST"&lt;/SPAN&gt;&lt;SPAN&gt;, uploadUrl, &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;xhr.setRequestHeader(&lt;/SPAN&gt;&lt;SPAN&gt;"Authorization"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Bearer "&lt;/SPAN&gt;&lt;SPAN&gt; + accessToken);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;xhr.setRequestHeader(&lt;/SPAN&gt;&lt;SPAN&gt;"Content-type"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"application/octet-stream"&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;xhr.setRequestHeader(&lt;/SPAN&gt;&lt;SPAN&gt;"Dropbox-API-Arg"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'{"path": "'&lt;/SPAN&gt;&lt;SPAN&gt; + path + &lt;/SPAN&gt;&lt;SPAN&gt;'"}'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;xhr.send(content);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 13 Jul 2022 10:12:04 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/609250#M2768</guid>
      <dc:creator>karanag</dc:creator>
      <dc:date>2022-07-13T10:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload file via Curl with Binary object input?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/609346#M2769</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1556562"&gt;@karanag&lt;/a&gt; In your code, you're sending the data in your 'content' variable, which just contains the string '"@" + imagePath', not the actual file data at that path. In the examples in &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation" target="_blank"&gt;the Dropbox API documentation&lt;/A&gt;, the "@" is a way of telling curl on the command line to read from the local filesystem at that path. That wouldn't necessarily work in other environments, such as using XMLHttpRequest like you are here. You'll need to update your code to pass in the actual file data. Please refer to the documentation for your platform for information on accessing file data.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 15:58:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/609346#M2769</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-07-13T15:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload file via Curl with Binary object input?</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/609348#M2770</link>
      <description>&lt;P&gt;Ahh, thanks! Will do a deep dive into the documentation&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 16:07:20 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/How-to-upload-file-via-Curl-with-Binary-object-input/m-p/609348#M2770</guid>
      <dc:creator>karanag</dc:creator>
      <dc:date>2022-07-13T16:07:20Z</dc:date>
    </item>
  </channel>
</rss>

