f512d94c74
git-subtree-dir: clients/ds-app git-subtree-mainline:a24e3e6f22git-subtree-split:5206cf3b0c
22 lines
852 B
Swift
22 lines
852 B
Swift
import Foundation
|
|
|
|
/// Original-file download URL builder. CRITICAL: this endpoint authenticates via the `?token=` QUERY
|
|
/// parameter, NOT an Authorization header (iframe/download compatibility). The token must live only in
|
|
/// the query. Callers must redact the token when logging the URL.
|
|
public enum DSDownload {
|
|
public static func fileURL(
|
|
base: DSBaseURL,
|
|
documentID id: Int,
|
|
accessToken: String,
|
|
download: Bool = true
|
|
) -> URL? {
|
|
let endpoint = base.url.appendingPathComponent("documents/\(id)/file")
|
|
var comps = URLComponents(url: endpoint, resolvingAgainstBaseURL: false)
|
|
comps?.queryItems = [
|
|
URLQueryItem(name: "token", value: accessToken),
|
|
URLQueryItem(name: "download", value: download ? "true" : "false"),
|
|
]
|
|
return comps?.url
|
|
}
|
|
}
|