Hello ,
I'm trying to upload a file to dropbox using UploadAsunc method . Everything works fine in the local system. But when i tried to publish and run from the server I'm having an exception or file doesn't get uploaded into the dropbox. Without the dropbox call everything works fine . Here is the code i'm trying to call when uplaoding it.
Try
Using handler As HttpClientHandler = New HttpClientHandler()
Using httpclient As HttpClient = New HttpClient(handler)
'httpclient.Timeout = TimeSpan.FromMinutes(20)
Dim _DropboxClient = New DropboxClient(ApiKeyDropBox, config)
Dim resultstring As String = UploadToDB(_DropboxClient, dropboxdir, docName, fileBytes)
_DropboxClient.Dispose()
If Not resultstring = "RanToCompletion" Then
ErrorMsg &= "The following error occured: " & resultstring
End If
End Using
End Using
Catch ex2 As Dropbox.Api.AuthException
ErrorMsg &= "Error details: " & ex2.Message.ToString()
Catch ex As HttpException
ErrorMsg &= "Error occured saving file to dropbox.<br /> Error Message: " & ex.InnerException.Message
End Try
Private Function UploadToDB(_DropboxClient As DropboxClient, Directory As String, Filename As String, Content As [Byte]()) As String
Try
Dim result As String = "Unknown"
Dim trycnt As String = 0
Dim tryLimit As String = 20
Dim respnse As Task(Of FileMetadata)
Using _mStream = New MemoryStream(Content)
respnse = _DropboxClient.Files.UploadAsync(Convert.ToString(Directory & Convert.ToString("/")) & Filename, WriteMode.Overwrite.Instance, body:=_mStream)
While Not respnse.IsCompleted And trycnt < tryLimit
Threading.Thread.Sleep(1000)
trycnt += 1
result = respnse.Status.ToString()
End While
UploadToDB = result
End Using
Catch ex2 As Dropbox.Api.HttpException
UploadToDB = ex2.Message.ToString()
End Try
End Function
Can you please say anything that I am doing worng or what is causing the problem.
This is the exception thrown : The type initializer for 'Dropbox.Api.DropboxRequestHandlerOptions' threw an exception.
Sometimes this is the exception i get: Could not load type 'System.Security.Authentication.SslProtocols' from assembly 'System.Net.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.