cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

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: 

Generate folder link manually

Highlighted

Generate folder link manually

Explorer | Level 3

I wish to send uploaded folder links to potential folder members manually, via my own constructed email, is this possible.

 

Also will I still have to add folder members using "AddFolderMemberAsync", before manually creating any email?

9 Replies 9
Highlighted

Re: Generate folder link manually

Dropboxer

If you want to share folders with other members programmatically but handle the communication yourself, you can do so. You will still need to call AddFolderMemberAsync; otherwise they won't have access to the folder.

To do so, you would want to:

Highlighted

Re: Generate folder link manually

Explorer | Level 3

OK, thanks for that.  I currently use

 

  Dim updated As ShareFolderLaunch = Await dbx.Sharing.ShareFolderAsync(filepath, Nothing, True)

how can I get SharedFolderMetadata.PreviewUrl from SharedFolderLaunch, I am not sure of how to do this, and it wont cast as a previewURL.

 

 

Highlighted

Re: Generate folder link manually

Dropboxer

The ShareFolderAsync method returns a ShareFolderLaunch. Per the ShareFolderAsync documentation, if a ShareFolderLaunch.AsyncJobId is returned, you need to periodically call CheckShareJobStatusAsync to see when the job (i.e., sharing the folder) is done. 

Once you get ShareFolderJobStatus.Complete from CheckShareJobStatusAsync, you can get the SharedFolderMetadata from ShareFolderJobStatus.Complete.Value.

Or, if the ShareFolderAsync method returns a ShareFolderLaunch.Complete directly, get the SharedFolderMetadata from ShareFolderLaunch.Complete.Value.

Either way, you can then get the URL from SharedFolderMetadata.PreviewUrl

Highlighted

Re: Generate folder link manually

Explorer | Level 3

Thanks for your help, all working well now, one more question, what is the best method for deleting the folder>? if it exists.

 

Highlighted

Re: Generate folder link manually

Dropboxer

To delete a file or folder, you should use DeleteAsync.

Note that deleting a folder removes it from the account, but it does not unshare it from other members. To remove a specific member from a shared folder, use RemoveFolderMemberAsync. To fully unshare a shared folder, use UnshareFolderAsync.

Highlighted

Re: Generate folder link manually

Explorer | Level 3
If I upload a file and say the same file exists, can I overwrite what is currently there, at the minute I get an exception pretty much saying the file already exists.
Highlighted

Re: Generate folder link manually

Dropboxer

Yes, you can control what happens when uploading to a path where a file already exists by specifying a particular WriteMode, e.g., to the `mode` parameter for UploadAsync. Please refer to those documentation pages for more information (and be sure to review the `autorename` parameter as well).

Highlighted

Re: Generate folder link manually

Explorer | Level 3

Yep, I have that set to WriteMode.Overwrite.Instance, what about larger files?

I am using :

 Private Async Function ChunkUploadAndCreateEmail(path As [String], stream As FileStream, chunkSize As Integer, dbx As DropboxClient, filepath As String) 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)
                    Else
                        Await dbx.Files.UploadSessionAppendV2Async(cursor, False, memStream)
                    End If
                End If


            End Using
        Next

    End Function

 

Highlighted

Re: Generate folder link manually

Dropboxer

When using upload sessions to upload larger files, you can likewise specify the WriteMode in the CommitInfo you pass to UploadSessionFinishAsync using CommitInfo.Mode.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?