You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
larschassing
8 years agoHelpful | Level 6
SwiftyDropbox createSharedLinkWithSettings (was createSharedLink)
Googling around led me to cocoadocs.org which seems to have an older version of SwiftyDropbox. It has createSharedLink(path:shortUrl:pendingUpload:) "Create a shared link. If a shared link already e...
- 8 years ago
The official documentation for the sharing routes for the latest version of SwiftyDropbox can be found be found here.
The createSharedLink method was deprecated in favor of createSharedLinkWithSettings to match updates to the Dropbox product itself.
If a link already exists, you can retrieve it using listSharedLinks.
- 8 years agoI can't make any promises as to if or when that would be added, but I'm sending that along as a feature request.
- 8 years ago
When I looked closer at listSharedLinks I noted the path and directOnly arguments, that helped.
This is what I ended up with:
func OldCreateSharedLink(url: URL, dropboxPath: String, completionHandler: @escaping (_ sharedLink: String) -> Void) { if let client = DropboxClientsManager.authorizedClient { let request = client.sharing.createSharedLinkWithSettings(path: dropboxPath) .response { response, error in if let response = response { print(response) completionHandler(response.url) } else if let error = error { print(error) switch error as CallError { case .routeError(let boxed, let requestId): print("RouteError[\(String(describing: requestId))]:") switch boxed.unboxed as Sharing.CreateSharedLinkWithSettingsError { case .sharedLinkAlreadyExists: let request2 = client.sharing.listSharedLinks(path: dropboxPath, cursor: nil, directOnly: true) .response { response, error in if let response = response { print(response) if let theFirstTheBest = response.links.first { completionHandler(theFirstTheBest.url) } } else if let error = error { print(error) } } print(request2) default: print("\(boxed.unboxed)") } default: break } } } print(request) } }
Thank you for your help
Greg-DB
Dropbox Staff
I can't make any promises as to if or when that would be added, but I'm sending that along as a feature request.
larschassing
8 years agoHelpful | Level 6
When I looked closer at listSharedLinks I noted the path and directOnly arguments, that helped.
This is what I ended up with:
func OldCreateSharedLink(url: URL, dropboxPath: String, completionHandler: @escaping (_ sharedLink: String) -> Void) { if let client = DropboxClientsManager.authorizedClient { let request = client.sharing.createSharedLinkWithSettings(path: dropboxPath) .response { response, error in if let response = response { print(response) completionHandler(response.url) } else if let error = error { print(error) switch error as CallError { case .routeError(let boxed, let requestId): print("RouteError[\(String(describing: requestId))]:") switch boxed.unboxed as Sharing.CreateSharedLinkWithSettingsError { case .sharedLinkAlreadyExists: let request2 = client.sharing.listSharedLinks(path: dropboxPath, cursor: nil, directOnly: true) .response { response, error in if let response = response { print(response) if let theFirstTheBest = response.links.first { completionHandler(theFirstTheBest.url) } } else if let error = error { print(error) } } print(request2) default: print("\(boxed.unboxed)") } default: break } } } print(request) } }
Thank you for your help
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,911 PostsLatest Activity: 4 hours agoIf 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!