diff --git a/Source/SwiftyDropbox/Shared/Handwritten/DropboxTransportClient.swift b/Source/SwiftyDropbox/Shared/Handwritten/DropboxTransportClient.swift index adc5c304..73cf19d4 100644 --- a/Source/SwiftyDropbox/Shared/Handwritten/DropboxTransportClient.swift +++ b/Source/SwiftyDropbox/Shared/Handwritten/DropboxTransportClient.swift @@ -510,7 +510,7 @@ public class DropboxTransportClientImpl: DropboxTransportClientInternal { for route: Route, baseHosts: BaseHosts = .default ) -> URL { - let urlString = "\(baseHosts.url(for: route.attributes.host))/\(route.namespace)/\(route.name)" + let urlString = "\(baseHosts.url(for: route.attributes))/\(route.namespace)/\(route.name)" return URL(string: urlString)! } @@ -529,6 +529,8 @@ public class BaseHosts: NSObject { @objc let contentHost: String @objc + var downloadContentHost: String + @objc let notifyHost: String @objc @@ -539,9 +541,20 @@ public class BaseHosts: NSObject { ) { self.apiHost = apiHost self.contentHost = contentHost + self.downloadContentHost = contentHost self.notifyHost = notifyHost } + @objc public convenience init( + apiHost: String, + contentHost: String, + downloadContentHost: String, + notifyHost: String + ) { + self.init(apiHost: apiHost, contentHost: contentHost, notifyHost: notifyHost) + self.downloadContentHost = downloadContentHost + } + public static var `default`: Self { .init( apiHost: ApiClientConstants.apiHost, @@ -552,12 +565,15 @@ public class BaseHosts: NSObject { } extension BaseHosts { - func url(for host: RouteHost) -> String { + func url(for attr: RouteAttributes) -> String { { - switch host { + switch attr.host { case .api: return apiHost case .content: + if attr.style == .download { + return downloadContentHost + } return contentHost case .notify: return notifyHost