We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

Blue_Maniac's avatar
Blue_Maniac
Explorer | Level 3
9 years ago

Setting My local folder as local storage and sync it trough my vb application without using DD

Hey everyones, i want to upload my folder to dropbox without compress it to rar and without using Dropbox Dekstop (DD). is there possible or there is some function that allow my local folder work as local storage like dropbox dekstop ?.

4 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    Dropbox does offer an API you can use to upload and download files without using the official Dropbox desktop application.

    You can find everything you need to get started with the Dropbox API, including documentation, tutorials, and SDKs here:

    https://www.dropbox.com/developers
  • Blue_Maniac's avatar
    Blue_Maniac
    Explorer | Level 3
    9 years ago

    I already read it greg, i want to pass the upload folder problem because when you using ordinary upload, you must compress it to rar, i want to make app work like Drobox Dekstop, where we can drag our folder without making rar of it and share it trough dropbox cloud storage. can i ?, can api do it ?

  • Blue_Maniac's avatar
    Blue_Maniac
    Explorer | Level 3
    9 years ago

    Hi greg i already made some improvement but, error keep haunting my program. so this is my code and the problem is this + $exception {"lookup_failed/closed/."} System.Exception {Dropbox.Api.ApiException<Dropbox.Api.Files.UploadSessionFinishError>}

     

    Private Async Sub UploadToolStripMenuItem2_Click(sender As Object, e As EventArgs) Handles UploadToolStripMenuItem2.Click
            Dim C As New OpenFileDialog
            C.Title = "Choose File"
            C.Filter = "All Files (*.*)|*.*"
            If C.ShowDialog = Windows.Forms.DialogResult.OK Then
                Dim fileinfos = Path.GetFileName(C.FileName)
                Dim filetempat = Path.GetFullPath(C.FileName)
                Dim tempat As String = direktori.Text & "/" & fileinfos
                Await Upload(filetempat, tempat)
    
            End If
        End Sub
        Async Function Upload(localPath As String, remotePath As String) As Task
            Const ChunkSize As Integer = 4096 * 1024
            Using fileStream = File.Open(localPath, FileMode.Open)
                If fileStream.Length <= ChunkSize Then
                    Await A.Files.UploadAsync(remotePath, body:=fileStream)
                Else
                    Await Me.ChunkUpload(remotePath, fileStream, ChunkSize)
                End If
            End Using
        End Function
    
        Private Async Function ChunkUpload(path As [String], stream As FileStream, chunkSize As Integer) As Task
            Dim numChunks As Integer = CInt(Math.Ceiling(CDbl(stream.Length) / chunkSize))
            Dim buffer As Byte() = New Byte(chunkSize - 1) {}
            Dim sessionId As String = Nothing
            For idx As Integer = 0 To numChunks - 1
                Dim byteRead = stream.Read(buffer, 0, chunkSize)
    
                Using memStream = New MemoryStream(buffer, 0, byteRead)
                    If idx = 0 Then
                        Dim result = Await A.Files.UploadSessionStartAsync(True, memStream)
                        sessionId = result.SessionId
                        kondisi.Text=byteRead
                    Else
                        Dim cursor = New UploadSessionCursor(sessionId, CULng(CUInt(chunkSize) * CUInt(idx)))
    
                        If idx = numChunks - 1 Then
                            Dim fileMetadata As FileMetadata = Await A.Files.UploadSessionFinishAsync(cursor, New CommitInfo(path), memStream)
                            MessageBox.Show("Upload Complete")
                            Console.WriteLine(fileMetadata.PathDisplay)
                        Else
                            Await A.Files.UploadSessionAppendV2Async(cursor, True, memStream)
                            MessageBox.Show("Upload Failed")
                        End If
                    End If
                End Using
            Next
        End Function

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 6 hours ago
410 Following

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

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!