Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

evry1falls's avatar
evry1falls
Collaborator | Level 8
7 years ago
Solved

VB .NET FileUpload using ChunkUpload() error lookup_failed/not_found...

I'm trying to use this code to upload a 12mb file in [Backups] folder. I converted this code from Git dotnet C# example to VB .NET code, but I get Error [File_Not_Found], when I debug this code I noticed that sessionID never returned with value either.

Await ChunkUpload("/Backups", "C:/File.png, (Int(ChunkSize)))
Private Async Function ChunkUpload(Ipath As String, chunkSize As Integer) As Task
chunkSize = 4096 * 1024 '4mb
Using stream = New MemoryStream(File.ReadAllBytes(Ipath))
Dim numChunks = Int(Math.Ceiling(stream.Length / chunkSize))
Console.WriteLine("Chunk upload file...")
Dim buffer() As Byte = New Byte(chunkSize) {}
Dim sessionId As String = String.Empty
Dim byteRead = stream.Read(buffer, 0, chunkSize)
For idx As Integer = 0 To numChunks - 1
idx += 1
Console.WriteLine("Start uploading chunk {0}", idx)
byteRead = stream.Read(buffer, 0, chunkSize)
Using memStream = New MemoryStream(buffer, 0, byteRead)
If (idx = 0) Then
Dim result = Await DBX.Files.UploadSessionStartAsync(body:=memStream)
sessionId = result.SessionIdElse
Dim Cursor As UploadSessionCursor = _
New UploadSessionCursor(sessionId, (CLng(chunkSize * idx))) If (idx = numChunks - 1) Then Await DBX.Files.UploadSessionFinishAsync(Cursor, _
New CommitInfo("/Backups" + "/" + "File.png"), memStream) Else Await DBX.Files.UploadSessionAppendV2Async(Cursor, body:=memStream) End If End If End Using Next End Using

While this code works fine with me with less large files 

Await DBX.Files.UploadAsync("/Backups" + "/" + "File.png",
                                                  WriteMode.Overwrite.Instance, True, Nothing, False, Nothing, False, memorystream)

Thank you.

  • It looks like the formatting of your code snippet has been lost, but I think the issue is that you're not actually calling 'UploadSessionStartAsync'. You immediately increment 'idx', so 'idx = 0' never returns true. I recommend adding some more logging and/or stepping through with a debugger to work out what's going on.

    For reference, there's an example of using upload sessions here, in C#, not VB, but it should still serve as a good example of the logic needed to run an upload session.

2 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    7 years ago

    It looks like the formatting of your code snippet has been lost, but I think the issue is that you're not actually calling 'UploadSessionStartAsync'. You immediately increment 'idx', so 'idx = 0' never returns true. I recommend adding some more logging and/or stepping through with a debugger to work out what's going on.

    For reference, there's an example of using upload sessions here, in C#, not VB, but it should still serve as a good example of the logic needed to run an upload session.

  • evry1falls's avatar
    evry1falls
    Collaborator | Level 8
    7 years ago

    Thank you that really helped a lot, I will also try the other suggestion in the other post of "overwrite"

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!