Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Mario B.17's avatar
Mario B.17
New member | Level 1
9 years ago

UploadAsync fails with small files > 100K and < 1MB

Hi,

I used the sample code for UploadAsync() method, in VB.Net, VS 2015, .Net 4.5, API v3.1.2, and for very small files it works perfectly.  However for somewhat larger files, ie 151K it never works.

I also tried the sample code that uses UploadSessionStartAsync,  UploadSessionAppendAsyncV2 and UploadSessionFinishAsync, with the same file (151K) and I got it to work only once when setting the chunksize to 24 * 1024, but it's extremely slow to upload.

Here's my code for UploadAsync;

Dim t As Files.FileMetadata
Dim fs As New MemoryStream(System.IO.File.ReadAllBytes(file))

Log("Uploading " & file)

Try
t = Await mDBX.Files.UploadAsync("/" & dbFolder & "/" & dbFileName,                                   Files.WriteMode.Overwrite.Instance, False, , True, fs)
Log("File uploaded: UFID = " & t.Id)

Catch ex As Exception
'MsgBox(ex.Message & vbCrLf & ex.StackTrace.ToString, MsgBoxStyle.Critical)

End Try

Any help would be greatly appreciated,

Thanks
Mario

 

The error I get is:

Error: Error while copying content to a stream.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Dropbox.Api.DropboxRequestHandler.<RequestJsonString>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Dropbox.Api.DropboxRequestHandler.<RequestJsonStringWithRetry>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Dropbox.Api.DropboxRequestHandler.<Dropbox.Api.Babel.ITransport.SendUploadRequestAsync>d__5`3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at TestDropBox.frmMain.VB$StateMachine_6_UploadFile.MoveNext() in \\vmware-host\shared folders\Documents\Visual Studio 2015\Projects\TestDropBox\TestDropBox\Form1.vb:line 62
Error: Unable to read data from the transport connection: The connection was closed.
at System.Net.ConnectStream.IOError(Exception exception, Boolean willThrow)
at System.Net.ConnectStream.EndWrite(IAsyncResult asyncResult)
at System.Net.Http.StreamToStreamCopy.BufferWrittenCallback(IAsyncResult ar)

3 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    Thanks for the report! We're taking a look.

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

    Hi Mario, I can't seem to reproduce this. Have you tried it from a different network connection? There might be something on your connection (e.g., proxy, anti-virus, firewall, etc.) that is interfering.

    Also, in the title, you said it fails for files "> 100K and < 1MB". You said it works for small files, but does it also work reliably for files >1 MB?

  • Mario B.17's avatar
    Mario B.17
    New member | Level 1
    9 years ago

    Hi Gregory, thanks for the quick reply.

    If failed for any files > 100K; sorry my title wasn't clear, by  < 1MB I meant I wasn't testing with files larger than 1MB.

    As for the proxy, anti-virus, etc.  I tried it on my 2nd internet connection (should have thought of that in the first place) and everything seems to work well!  Unfortunately I'm no export when it comes to routers, etc., so I'm not sure why the modem of my main internet connections fails like that.

    I'll try to look into this and will post my findings.

    Thanks again for your help, much appreciated!
    Mario

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

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!