cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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: 

Large Data Upload

Large Data Upload

solsupp
Explorer | Level 3

Now have large data upload working, only 1 thing I cant do is share the folder.  Errors on bold text, how do I get the parent shared folder ID after upload.

 Private Async Function ChunkUpload(path As [String], stream As FileStream, chunkSize As Integer, dbx As DropboxClient) 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 = 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 dbx.Files.UploadSessionStartAsync(False, memStream)
                    sessionId = result.SessionId
                Else
                    Dim cursor = New UploadSessionCursor(sessionId, CULng(CUInt(chunkSize) * CUInt(idx)))

                    If idx = numChunks - 1 Then
                        Dim fileMetadata As FileMetadata = Await dbx.Files.UploadSessionFinishAsync(cursor, New CommitInfo(path), memStream)
                        Console.WriteLine(fileMetadata.PathDisplay)

                        Dim myIssueID As Integer = CInt(GridView1.GetRowCellValue(GridView1.FocusedRowHandle, "Issue_ID").ToString)
                        Dim myMembers() As AddMember = Nothing

                        If GridView1.SelectedRowsCount > 0 Then

                            Dim myIssueRecipientsDatatable As System.Data.DataTable
                            Dim myIssueRecipientsTableAdapter As ArchetypeDBDataSetTableAdapters.draw_issueesTableAdapter = New ArchetypeDBDataSetTableAdapters.draw_issueesTableAdapter
                            myIssueRecipientsDatatable = myIssueRecipientsTableAdapter.GetDataByIssueID(False, myIssueID)

                            If fileMetadata.SharingInfo.ParentSharedFolderId IsNot Nothing Then
                                For Each myIssuee As DataRow In myIssueRecipientsDatatable.Rows
                                    If myIssuee.Item("DREASON").ToString IsNot Nothing Then
                                        myMembers = {New AddMember(New MemberSelector.Email(myIssuee.Item("DREASON").ToString), Nothing)}
                                        Await dbx.Sharing.AddFolderMemberAsync(fileMetadata.SharingInfo.ParentSharedFolderId, myMembers, False, "A Document Issue has been created by " & fnGetCompanyName() & " as you are part of the issue distribution, this ZipFile has been made available to you.")
                                    End If
                                Next
                            End If

                        End If

                        MsgBox("Successfully Uploaded")
                    Else
                        Await dbx.Files.UploadSessionAppendV2Async(cursor, False, memStream)
                    End If
                End If
            End Using
        Next
    End Function

10 Replies 10

Greg-DB
Dropbox Staff

Making the call and catching that exception is fine, but if you want to check beforehand, you can call FilesUserRoutes.GetMetadataAsync for the folder itself and check the returned FolderMetadata.SharingInfo. (Or, you can list all of the shared folders on the account using SharingUserRoutes.ListFoldersAsync/SharingUserRoutes.ListFoldersContinueAsync.)

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    solsupp Explorer | Level 3
What do Dropbox user levels mean?