cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in hearing how one of our Community members uses Dropbox for sailing trips? Read all about it 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: 

createSharedLinkWithSettings: Use external link in iOS app

createSharedLinkWithSettings: Use external link in iOS app

petepete717
Helpful | Level 6
Go to solution

I am creating a sharing link using 

 

client.sharing.createSharedLinkWithSettings(path: "/MyTestPath").response { response, error in

            if let link = response {

                let linkURL = link.url 

                // Send linkURL to be accessed through another DB account in another app

            } else {

                print("Error sharing:", error)

            }

        }

 

I would like to open this generated  link in a different app with a different Dropbox account. And then to access the shared folder in order to up- and download files by the app.

Unfortunately, I am stuck and seem to be missing something. Can anyone point me in the right direction? Thanks very much.

1 Accepted Solution

Accepted Solutions

petepete717
Helpful | Level 6
Go to solution

Thank you very much. I didn't understand that I needed to run the result through a switch statement as the ShareFolderLaunch returned is a Dropbox-union:

 

client.share.shareFolder(path:"/MyTestPath").response { shareResult, error in

    switch shareResult {

        case .complete(let shareData):

            // Use metadata here

        case .asyncJobId(.....

 

Now it works perfectly!

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

You can use createSharedLinkWithSettings to create a shared link to any file or folder to allow access to view that file or folder, but to enable other people to make changes in a folder, you should share the folder itself. You can use shareFolder and addFolderMember to do so.

 

You can find more information in the Sharing Guide.

petepete717
Helpful | Level 6
Go to solution

Thanks Greg. 

While I can grasp the overall concept - thanks for pointing me in the direction of folder shareFolder and addFolderMember - I am still struggling. I don't know how to obtain the shared_folder_id after running client.sharing.shareFolder(path...

I can't find any sample code in Swift for the sharing functionality? Can you please point me in the right direction.

Greg-DB
Dropbox Staff
Go to solution

I don't believe we have sample code for these in particular, but you can call those methods much the same way as you would call createSharedLinkWithSettings, and get the information from the response object.

 

Note that the folder sharing operation may run asynchronously though. If successful, the shareFolder response will be a ShareFolderLaunch which will either be 'complete' and give you a SharedFolderMetadata directly, or 'asyncJobId', in which case you poll checkShareJobStatus to get the SharedFolderMetadata. Either way, once you get the SharedFolderMetadata, you can get the shared folder ID from SharedFolderMetadata.sharedFolderId.

petepete717
Helpful | Level 6
Go to solution

Thank you very much. I didn't understand that I needed to run the result through a switch statement as the ShareFolderLaunch returned is a Dropbox-union:

 

client.share.shareFolder(path:"/MyTestPath").response { shareResult, error in

    switch shareResult {

        case .complete(let shareData):

            // Use metadata here

        case .asyncJobId(.....

 

Now it works perfectly!

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    petepete717 Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?