cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 

Api v2 dropbox.files_upload_session_finish offset error

Yashik
Explorer | Level 4
problem is the offset of files_upload_session_finish , I am using the content length for the offset but it is giving error

Code:
import dropbox,requests,sys
def down(url):

dbx=dropbox.Dropbox(AccessToken)

size=45*1024
a=0
i=0
p=0
params = {'':'', 'render':'download'}
r=requests.get(url,params=params,stream=True)
clen=r.headers['Content-length']

for chunk in r.iter_content(chunk_size=size):

if chunk:
i+=1
a+=len(chunk)
c=a/(1024)
print('\n'+str(c)+' of '+str(clen))
if i==1:
strtid = dbx.files_upload_session_start(chunk)
cursor = dropbox.files.UploadSessionCursor(session_id=strtid.session_id,offset=len(chunk))
commit = dropbox.files.CommitInfo(path='/sourttt',mode=dropbox.files.WriteMode('add'))
if ((int(clen)-p))<=size:
cur=dropbox.files.UploadSessionCursor(session_id=strtid.session_id,offset=int(a))
dbx.files_upload_session_finish(chunk,cur,commit)


else:
dbx.files_upload_session_append(chunk,cursor.session_id,a)
p=a

url='https://speedtest.ftp.otenet.gr/files/test100k.db'
down(url)

Error:

dropbox.exceptions.ApiError: ('281cb346aa41adc8436f415fc4d0de0a', UploadSessionFinishError('lookup_failed', UploadSessionLookupError('incorrect_offset', UploadSessionOffsetError(correct_offset=138240))))

The content length is 100Kb(102400) but the error showing me the correct offset is 138240 and the difference between those are 35Kb . What should I do for offset value in files_upload_session_finish
?
2 Replies 2

Re: Api v2 dropbox.files_upload_session_finish offset error

Yashik
Explorer | Level 4

Is there any way to use ```<pre>``` tag on my code so the code could be more understanding

Re: Api v2 dropbox.files_upload_session_finish offset error

Dropboxer
Dropboxer

@Yashik It looks like you had some trouble with the forum's spam filter and so made this extra thread. I'll close this one and resume the conversation on your original thread so we can keep that in one place:

 

https://www.dropboxforum.com/t5/General-Discussion/Dropbox-v2-upload-cursor-offset-confusion/m-p/288...

 

And yes, the forum's "Rich Text" editor has a code button you can use to get code formatting. The button has a label like "</>".

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?