<?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: python upload big file example in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166627#M6013</link>
    <description>&lt;P&gt;We don't currently have an official sample app for that,&amp;nbsp;but I'll be sure to pass this along as request for one.&lt;/P&gt;
&lt;P&gt;Here's a quick example I put together though: (note, I haven't tested this extensively, and it doesn't have any error handling)&lt;/P&gt;
&lt;PRE class="remarkup-code"&gt;f = open(file_path)
file_size = os.path.getsize(file_path)

CHUNK_SIZE = 4 * 1024 * 1024

if file_size &amp;lt;= CHUNK_SIZE:

    print dbx.files_upload(f, dest_path)

else:

    upload_session_start_result = dbx.files_upload_session_start(f.read(CHUNK_SIZE))
    cursor = dropbox.files.UploadSessionCursor(session_id=upload_session_start_result.session_id,
                                               offset=f.tell())
    commit = dropbox.files.CommitInfo(path=dest_path)

    while f.tell() &amp;lt; file_size:
        if ((file_size - f.tell()) &amp;lt;= CHUNK_SIZE):
            print dbx.files_upload_session_finish(f.read(CHUNK_SIZE),
                                            cursor,
                                            commit)
        else:
            dbx.files_upload_session_append(f.read(CHUNK_SIZE),
                                            cursor.session_id,
                                            cursor.offset)
            cursor.offset = f.tell()&lt;/PRE&gt;</description>
    <pubDate>Fri, 29 Jan 2016 06:53:20 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2016-01-29T06:53:20Z</dc:date>
    <item>
      <title>python upload big file example</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166626#M6012</link>
      <description>&lt;P&gt;Can you please share an example code of how to upload big files (size &amp;gt; 150 mb) with python api v2 sdk?&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:36:24 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166626#M6012</guid>
      <dc:creator>hsyn</dc:creator>
      <dc:date>2019-05-29T09:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: python upload big file example</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166627#M6013</link>
      <description>&lt;P&gt;We don't currently have an official sample app for that,&amp;nbsp;but I'll be sure to pass this along as request for one.&lt;/P&gt;
&lt;P&gt;Here's a quick example I put together though: (note, I haven't tested this extensively, and it doesn't have any error handling)&lt;/P&gt;
&lt;PRE class="remarkup-code"&gt;f = open(file_path)
file_size = os.path.getsize(file_path)

CHUNK_SIZE = 4 * 1024 * 1024

if file_size &amp;lt;= CHUNK_SIZE:

    print dbx.files_upload(f, dest_path)

else:

    upload_session_start_result = dbx.files_upload_session_start(f.read(CHUNK_SIZE))
    cursor = dropbox.files.UploadSessionCursor(session_id=upload_session_start_result.session_id,
                                               offset=f.tell())
    commit = dropbox.files.CommitInfo(path=dest_path)

    while f.tell() &amp;lt; file_size:
        if ((file_size - f.tell()) &amp;lt;= CHUNK_SIZE):
            print dbx.files_upload_session_finish(f.read(CHUNK_SIZE),
                                            cursor,
                                            commit)
        else:
            dbx.files_upload_session_append(f.read(CHUNK_SIZE),
                                            cursor.session_id,
                                            cursor.offset)
            cursor.offset = f.tell()&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jan 2016 06:53:20 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166627#M6013</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-01-29T06:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: python upload big file example</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166628#M6014</link>
      <description>&lt;P&gt;Thanks Gregory,&lt;/P&gt;
&lt;P&gt;It is working without any problem.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Only thing is in python3 file must be opended in binary format like this:&lt;/P&gt;
&lt;P&gt;file = open(file_path,'rb')&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 17:31:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166628#M6014</guid>
      <dc:creator>hsyn</dc:creator>
      <dc:date>2016-01-29T17:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: python upload big file example</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166629#M6015</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;
&lt;P&gt;Is session_upload supposed to be horrendously slow?&lt;/P&gt;
&lt;P&gt;I have&amp;nbsp;written some code, which (honestly) is a bit more convoluted than Gregory's sample, but in essence does exactly the same thing and each call to "files_upload_session_append" is taking "forever" to return. &amp;nbsp;I even get "connection aborted" here and there... &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;I am sending in 4M chunks as in Gregory's sample...&lt;/P&gt;
&lt;P&gt;Any hints or this is probably my network? &amp;nbsp;(will test using other connections and post back if anything changes!)&lt;/P&gt;
&lt;P&gt;TIA,&lt;/P&gt;
&lt;P&gt;Paulo&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 06:17:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166629#M6015</guid>
      <dc:creator>Paulo L.</dc:creator>
      <dc:date>2016-04-27T06:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: python upload big file example</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166630#M6016</link>
      <description>&lt;P&gt;Hi Paulo, the majority of the time taken by the files_upload_session_append call should be the time spent actually sending the file content to&amp;nbsp;Dropbox over the network. I can't reproduce the issues you're seeing, so it does seem likely these issues are related to your network connection.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, note that all of the Dropbox servers are located in the US. Your connection speed to Dropbox depends on the routing you get between your ISP and our servers, and may be slower than your ISP's rated speeds.&lt;/P&gt;
&lt;P&gt;Sometimes resetting or retrying your connection gets you a different route and better speeds, but that is outside of our control. Some ISPs also throttle sustained connections so if you see an initial high connection speed followed by lower speeds, that could be the reason.&lt;/P&gt;
&lt;P&gt;Finally, if you think there may be something interfering with your connection to the&amp;nbsp;Dropbox API (e.g., a firewall, proxy, or other security software) you can try testing your ability to connect to&amp;nbsp;content.dropboxapi.com.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 06:51:58 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166630#M6016</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-04-27T06:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: python upload big file example</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166631#M6017</link>
      <description>&lt;P&gt;Hi Gregory,&lt;/P&gt;
&lt;P&gt;I have made some tests under different connections, and my speed issues do seem to be network-related.&lt;/P&gt;
&lt;P&gt;Thanks for the feedback and the sample code; I will use it to optimize mine.&lt;/P&gt;
&lt;P&gt;I will publish my results in Github and post back the link here for the convenience of the community.&lt;/P&gt;
&lt;P&gt;Thanks again,&lt;/P&gt;
&lt;P&gt;Paulo.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 20:03:32 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166631#M6017</guid>
      <dc:creator>Paulo L.</dc:creator>
      <dc:date>2016-04-27T20:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: python upload big file example</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166632#M6018</link>
      <description>&lt;P&gt;Hi Gregory,&lt;/P&gt;
&lt;P&gt;&amp;lt;&amp;lt;&amp;lt;CHUNK_SIZE = 4 * 1024 * 1024&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;
&lt;P&gt;Is there any reason why you chose 4mb in your python example code? (thanks BTW)&lt;/P&gt;
&lt;P&gt;Why chose between a single files_upload call, and a chunked upload session, at 4mb when 150mb is the upper limit for the former? Also why transmit&amp;nbsp;in 4mb blocks when 150mb is permitted?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is 4mb&amp;nbsp;preferred for some reason? Is there some efficiency gain? I see that it has been claimed that 4mb is DropBox's chunk size for de-duplication. Is this a factor. or were just intending to minimise resources in your demonstration snippet?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blog.fosketts.net/2011/07/11/dropbox-data-format-deduplication/" rel="nofollow noreferrer"&gt;http://blog.fosketts.net/2011/07/11/dropbox-data-format-deduplication/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2016 13:14:23 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166632#M6018</guid>
      <dc:creator>barry m.10</dc:creator>
      <dc:date>2016-05-03T13:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: python upload big file example</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166633#M6019</link>
      <description>&lt;P&gt;Hi Barry, there wasn't really any particular reason for 4 MB in my sample. A larger size could certainly improve overall performance (by reducing the overhead of making more connections), but it comes at the cost of making each call more likely to fail. Further, the app would have to re-upload more data for any particular failed call.&lt;/P&gt;
&lt;P&gt;So, it's really just a tradeoff for you to make based on the use cases for your app. E.g., if you know your app is likely to be used with weak, slow, or unreliable network connections, a smaller chunk size is better. Otherwise, a larger chunk size would be good.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2016 01:20:03 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/m-p/166633#M6019</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-05-04T01:20:03Z</dc:date>
    </item>
  </channel>
</rss>

