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

Forum Discussion

solsupp's avatar
solsupp
Explorer | Level 3
7 years ago

Dropbox API

Just programatically created a file sharing link in VB .net, once a recipient click on the link they get a message "You don’t have access to this content. You’re signed in as xxxx@xxxxx.

I just want recipient to be able to download or view uploaded file, is this possible, am I missing a step for sharing the file.

 

9 Replies

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

    You should be able to create a shared link that anyone can access using CreateSharedLinkWithSettingsAsync. (Though, content may be subject to team and/or shared folder policies.)

    Is that what you're using? Please share the code/output if something isn't working as expected.

  • solsupp's avatar
    solsupp
    Explorer | Level 3
    7 years ago
    Ah ok, does the recipient still need to be logged into Dropbox, I was hoping to send link that anyone can download without having to log in.
  • solsupp's avatar
    solsupp
    Explorer | Level 3
    7 years ago

    I use :

     

    Private Async Function Dropboxnotification(path As [String], stream As FileStream, chunkSize As Integer, dbx As DropboxClient, filepath As String) As Task
    
            Dim updated As Task(Of ShareFolderLaunch) = Nothing
            updated = dbx.Sharing.ShareFolderAsync(filepath, Nothing, True)
    
    
            Dim myShared As Task(Of SharedFileMetadata) = Nothing
            myShared = dbx.Sharing.GetFileMetadataAsync(path)
    
    
            Dim myuploaded As ShareFolderJobStatus = Nothing
            Dim myPreview As SharedFolderMetadata = Nothing
            Dim mySharedLink As SharedLinkMetadata = Nothing
    
            Dim myDropBoxLink As String = Nothing
    
            Try
    
                If updated.Result.AsAsyncJobId.Value IsNot Nothing Then
    
                    Dim myUploadReady As Boolean = False
                    Dim myLinkReady As Boolean = False
    
                    Do Until myUploadReady = True
                        myuploaded = Await dbx.Sharing.CheckShareJobStatusAsync(updated.Result.AsAsyncJobId.Value)
                        If myuploaded.IsComplete = True Then
                            myPreview = myuploaded.AsComplete.Value
                            myDropBoxLink = myPreview.PreviewUrl
                            myUploadReady = True
                            Exit Do
                        End If
                    Loop
    
    
                    Dim myIssueID As Integer = CInt(GridView1.GetRowCellValue(GridView1.FocusedRowHandle, "Issue_ID").ToString)
                    Dim myMembers() As AddMember = Nothing
    
                    Me.Draw_issuesTableAdapter.UpdateDropboxLink(myDropBoxLink, myIssueID)
                    GridView1.SetRowCellValue(GridView1.FocusedRowHandle, "XXXlong", myDropBoxLink)
    
                    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)
    
                        Try
    
    
                            If myPreview.SharedFolderId 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))}
                                        Await dbx.Sharing.AddFolderMemberAsync(myPreview.SharedFolderId, 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
                        Catch ex As SystemException
                        End Try
    
                    End If
    
                End If
    
            Catch ex As System.AggregateException
                If ex.HResult = -2146233088 Then
                 
                    'DevExpress.XtraEditors.XtraMessageBox.Show("This file already exists, cannot upload!", "oops, something has happened!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1)
                    Exit Function
                End If
            End Try
    
        End Function

    I get exception that shared link aleady exists, if i try to use CreateSharedLinkWithSettingsAsync , can I return the shared link from already shared file, not the url, as the returned url needs user to be signed in.

  • solsupp's avatar
    solsupp
    Explorer | Level 3
    7 years ago
    Thanks, one more question, I maybe need to view the files from the folder, as the file I upload is a zip file, is there an equivalent shared folder link?
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    7 years ago

    The CreateSharedLinkWithSettingsAsync method can be used to create shared links for files or folders.

    If you access a shared link for a zip file in particular, the Dropbox web site will allow the user to browse through the contents of the zip file.

  • solsupp's avatar
    solsupp
    Explorer | Level 3
    7 years ago

    How do I check a shared link exists, I am using

     

      Dim mySharedFolderLink As Task(Of SharedLinkMetadata) = Nothing
            mySharedFolderLink = dbx.Sharing.CreateSharedLinkWithSettingsAsync(path)

     

    Not sure what to do next, to find out if folder exists

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!