cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

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

evry1falls
Collaborator | Level 8

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.

1 Accepted Solution

Accepted Solutions

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

Greg-DB
Dropboxer

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.

View solution in original post

2 Replies 2

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

Greg-DB
Dropboxer

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.

View solution in original post

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

evry1falls
Collaborator | Level 8

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

Who's talking

Top contributors to this post

  • User avatar
    evry1falls Collaborator | Level 8
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?