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);
}
}
}
}
}