One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
urs32
7 years agoExplorer | Level 3
Upload cuts sometimes the file - corrupted files on DropBox
Hello,
i have a problem with uploads on Android apps. I use the c# v2 DropBox api. Sometimes the uploaded file are cutted at the end of a chunk (128*1024) on DropBox drive and no error appears in the code.
So at the end there are some corrupted files on DropBox and the Android client has no error state. What can i do?
I use this standard code to upload:
private async Task ChunkUploadAsync(String path, FileStream stream, int chunkSize, DropboxClient client) { ulong numChunks = (ulong)Math.Ceiling((double)stream.Length / chunkSize); if (this.bufferUpload == null) this.bufferUpload = new byte[chunkSize]; string sessionId = null; for (ulong idx = 0; idx < numChunks; idx++) { var byteRead = stream.Read(this.bufferUpload, 0, chunkSize); using (var memStream = new MemoryStream(this.bufferUpload, 0, byteRead)) { if (idx == 0) { var result = await client.Files.UploadSessionStartAsync(false, memStream); sessionId = result.SessionId; } else { var cursor = new UploadSessionCursor(sessionId, (ulong)chunkSize * idx); if (idx == numChunks - 1) { FileMetadata fileMetadata = await client.Files.UploadSessionFinishAsync(cursor, new CommitInfo(path), memStream); } else { await client.Files.UploadSessionAppendV2Async(cursor, false, memStream); } } } } }
- Greg-DB
Dropbox Staff
I don't see anything obviously wrong here, and since you mention you don't get any error, it sounds like there may be an issue reading from the `FileStream stream` in the first place.
Can you add some logging to see if you're getting all of the expected data from that stream to begin with?
- urs32Explorer | Level 3
Thank you, i tested with logs and i think its an filestream error.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 15 hours ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!