Closed bpollman closed 1 month ago
Jira or Github issue link, if applicable.
To use our own CDN, we need the equivalent of ImageCDN to intercept a given URL and provide a signed URL when dealing with File attachments.
ImageCDN
Example of how we are using it to make an async call for a signed URL.
public final class CustomFileCDN: FileCDN { static var customCDNURL = "mycustomCDN.com" let attachmentService: ChatAttachmentService init(attachmentService: ChatAttachmentService) { self.attachmentService = attachmentService } public func adjustedURL(for url: URL, completion: @escaping ((Result<URL, any Error>) -> Void)) { Task { do { let signedUrl = try await signedUrl(for: url) completion(.success(signedUrl)) } catch { completion(.failure(error)) } } } func signedUrl(for url: URL) async throws -> URL { guard let components = URLComponents(url: url, resolvingAgainstBaseURL: true), let host = components.host, host.contains(Self.customCDNURL) else { return url } return try await self.attachmentService.signedDownloadUrl(url) } }
Describe the steps how this change can be tested (or why it can't be tested).
Add relevant screenshots or videos showcasing the changes.
๐ Issue Link
Jira or Github issue link, if applicable.
๐ฏ Goal
To use our own CDN, we need the equivalent of
ImageCDN
to intercept a given URL and provide a signed URL when dealing with File attachments.๐ Implementation
Example of how we are using it to make an async call for a signed URL.
๐งช Testing
Describe the steps how this change can be tested (or why it can't be tested).
๐จ Changes
Add relevant screenshots or videos showcasing the changes.
โ๏ธ Checklist