使用dropnet上传到Dropbox

时间:2014-04-30 11:33:53

标签: dropbox dropnet

我开始开发一个项目来创建一些dll来与Dropbox(桌面)通信。

在Google搜索了一段时间后,我发现了dropnet并开始使用它。

我在访问令牌时遇到两个问题,以及我上传时的问题。

代码:

Dim client As DropNetClient

        If Not dropboxLoggedIn Then
            client = New DropNetClient("XXXXXXXXXXXX", "YYYYYYYYYY")
            client.UseSandbox = True
            Dim token As UserLogin
            Dim url As String = ""
            Try
                token = client.GetToken()
                url = client.BuildAuthorizeUrl()

                Dim aw As New AuthorizationWindow(url)
                aw.ShowDialog()

                If (Not dropboxLoggedIn) Then
                    client.GetAccessToken()
                    dropboxAsecret = client.UserLogin.Secret
                    dropboxAtoken = client.UserLogin.Token
                Else
                    client.UserLogin.Token = dropboxAtoken
                    client.UserLogin.Secret = dropboxAsecret
                End If
                dropboxLoggedIn = True

                Dim rawData As Byte() = File.ReadAllBytes("c:\users\mysuser\Pictures\anypic.JPG")
                Dim result As MetaData = client.UploadFile("/", "anypic.JPG", rawData)    
            Catch ex As DropNet.Exceptions.DropboxException
                MessageBox.Show(ex.Message)
            End Try
        Else
            Try
                client = New DropNetClient("XXXXXXXXXXXX", "YYYYYYYYYY", dropboxAtoken, dropboxAsecret)
                client.UseSandbox = True
                Dim rawData As Byte() = File.ReadAllBytes("c:\users\mysuser\Pictures\anypic.JPG")
                Dim result As MetaData = client.UploadFile("/", "anypic.JPG", rawData)
            Catch ex As DropNet.Exceptions.DropboxException
                MessageBox.Show(ex.Message)
            End Try


        End If

因此,在我上传后,没有任何内容会转到dropbox文件夹。结果在属性中没有任何内容。很奇怪,因为没有给出错误。 此外,GetAccessToken并不总是有效。

有人可以帮忙吗?

0 个答案:

没有答案