-
Notifications
You must be signed in to change notification settings - Fork 232
Unified CDN & Media Loading Architecture (v5) #4056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
aeb64e3
Add CDN, CDNUploader protocols and replace CDNClient/AttachmentUploader
nuno-vieira 6834ee5
Add ImageLoader, VideoLoader, and ImageDownloading protocols in Streaβ¦
nuno-vieira 5657a91
Replace old ImageCDN/ImageLoading/VideoLoading in StreamChatUI
nuno-vieira e6586f4
Update test infrastructure for new CDN/loader protocols
nuno-vieira c306d8b
Rename NukeImageDownloader and NukeImageProcessor to Stream prefix
nuno-vieira 926a655
Rename CDNUploader to CDNStorage
nuno-vieira 6ee5c32
Remove maxAttachmentSize from CDNStorage protocol
nuno-vieira ea6adf9
Rename CDN to CDNRequester
nuno-vieira 65212f7
Introduce options parameters to the CDNStorage and CDNRequester
nuno-vieira d4bcbbd
Move CDNRequest object to CDNRequester
nuno-vieira 5ef94cf
PR Feedback
nuno-vieira 893ddca
Merge branch 'develop' into add/improve-custom-cdn
nuno-vieira e587f1d
Fix import issues
nuno-vieira 76d1f77
Fix tests not compiling
nuno-vieira 8670250
Fix Xcode project
nuno-vieira 7d70b7a
Fix targets of loaders in common module
nuno-vieira 7024b1c
Missing StreamChat import
nuno-vieira 62ceeac
Move ImageResize to common module
nuno-vieira f6efc35
Fix compiling mock loaders
nuno-vieira 8bfa60c
Merge branch 'develop' into add/improve-custom-cdn
nuno-vieira b0a30c2
Fix snapshot tests
nuno-vieira 499d81d
Re-record snapshots
nuno-vieira 70e066d
Fix StreamChatUI tests
nuno-vieira 0ad546d
Fix swiftformat
nuno-vieira 0187194
Fix sendable warning in StreamVideoLoader
nuno-vieira fbb7826
Add remoteURL parameter to downloadAttachment
nuno-vieira 113ad3b
Add tests for downloadAttachment remoteURL parameter
nuno-vieira 8b83aa8
Update changelog
nuno-vieira c60a3e9
Pass CDNRequester on every loader call instead of storing it
nuno-vieira f1ec6cb
Introduce Options pattern for ImageLoader and VideoLoader protocols
nuno-vieira 549ec4e
Merge ImageLoader and VideoLoader into unified MediaLoader protocol
nuno-vieira 49ce1cd
Add wrapper result types and make videoAsset async
nuno-vieira 7e412fc
Remove cdnRequester and cdnStorage from ChatClient
nuno-vieira d0aa17a
Refine ImageDownloading with Options pattern and DownloadedImage output
nuno-vieira e288332
Fix caching key using original URL instead of final resized URL
nuno-vieira 5830e77
Unify video loading via MediaLoader and rename videoAsset to loadVideβ¦
nuno-vieira 8e78882
Merge branch 'develop' into add/improve-custom-cdn
nuno-vieira c84b40e
Make UploadedFile sendable
nuno-vieira 197db4f
Make StreamCDNRequester Sendable
nuno-vieira 1594527
Fix silent no-op when StreamMediaLoader is deallocated during image load
nuno-vieira 8308a3d
Make StreamImageDownloader final Sendable
nuno-vieira c0b0d64
Fix loadImages results order
nuno-vieira bfadff8
Move COmponents initializer
nuno-vieira 8b65898
Improve test coverage
nuno-vieira 71d5083
Remove loadImages from MediaLoader, since it is not used
nuno-vieira 82db0b3
Fix compilation
nuno-vieira 383b3d3
Refactor avatar views to use the correct components
nuno-vieira a2d6ad9
Fix avatar tests
nuno-vieira 108de47
Update CDNStorage test coverage
nuno-vieira d7c1019
Fix completion handler not always called in StreamMediaLoader
nuno-vieira 0df573c
Fix completion handler not always called in StreamCDNStorage
nuno-vieira 6d43eb6
Rename StreamCDN_Tests.swift to StreamCDNRequester_Tests.swift
nuno-vieira b2c26fd
Rename CustomCDNClient.swift and StreamCDNClient_Tests.swift
nuno-vieira f7f3874
Fix stale CDNClient references and misleading log strings
nuno-vieira 2fca66f
Improve StreamCDNStorage test coverage
nuno-vieira fb7f51c
Remove URL-based loadVideoPreview, use attachment variant only
nuno-vieira 9bd596c
Explain video preview local caching
nuno-vieira b53149a
Remove default implementation of loadVideoAsset from MediaLoader
nuno-vieira fdcbfa0
Update Sources/StreamChatCommonUI/ImageLoading/MediaLoader.swift
nuno-vieira 0ae2e26
Move cdnRequester out of ChatClientConfig into UI layer
nuno-vieira df96c6b
Fix tests related to CDNRequester moving
nuno-vieira c5a0aea
Fix StreamCDNStorage tests
nuno-vieira 9a09605
Fix wrong log message
nuno-vieira b6735e7
Introduce back the local only video preview
nuno-vieira 9c5dccf
Fix message content view tests
nuno-vieira 2bd362a
Fix video composer preview tests
nuno-vieira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
Sources/StreamChat/APIClient/AttachmentUploader/AttachmentUploader.swift
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // | ||
| // Copyright Β© 2026 Stream.io Inc. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| /// A protocol for transforming CDN URLs before loading images and files. | ||
| /// | ||
| /// Implement this protocol to add signing, authentication headers, | ||
| /// resize query parameters, or to rewrite the CDN host. | ||
| /// | ||
| /// All methods use completion handlers to support asynchronous operations | ||
| /// such as fetching pre-signed URLs from a server. | ||
| public protocol CDN: Sendable { | ||
| /// Transforms an image URL for loading. | ||
| /// | ||
| /// Called before every image load. Use this to add signing, | ||
| /// auth headers, resize query params, or rewrite the host. | ||
| /// | ||
| /// - Parameters: | ||
| /// - url: The original image URL. | ||
| /// - resize: Optional resize parameters for server-side resizing. | ||
| /// - completion: A completion handler with the transformed request. | ||
| func imageRequest( | ||
| for url: URL, | ||
| resize: ImageResize?, | ||
| completion: @escaping (Result<CDNRequest, Error>) -> Void | ||
| ) | ||
|
|
||
| /// Transforms a file or video URL for loading or playback. | ||
| /// | ||
| /// Called before loading non-image media. Use this to add signing | ||
| /// or auth headers for file and video access. | ||
| /// | ||
| /// - Parameters: | ||
| /// - url: The original file/video URL. | ||
| /// - completion: A completion handler with the transformed request. | ||
| func fileRequest( | ||
| for url: URL, | ||
| completion: @escaping (Result<CDNRequest, Error>) -> Void | ||
| ) | ||
| } | ||
|
|
||
| // MARK: - Async/Await Extensions | ||
|
|
||
| extension CDN { | ||
| /// Transforms an image URL for loading. | ||
| public func imageRequest(for url: URL, resize: ImageResize? = nil) async throws -> CDNRequest { | ||
| try await withCheckedThrowingContinuation { continuation in | ||
| imageRequest(for: url, resize: resize) { result in | ||
| continuation.resume(with: result) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Transforms a file or video URL for loading or playback. | ||
| public func fileRequest(for url: URL) async throws -> CDNRequest { | ||
| try await withCheckedThrowingContinuation { continuation in | ||
| fileRequest(for: url) { result in | ||
| continuation.resume(with: result) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // | ||
| // Copyright Β© 2026 Stream.io Inc. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| /// The result of a CDN URL transformation, containing the final URL, | ||
| /// optional HTTP headers, and an optional caching key. | ||
| public struct CDNRequest: Sendable { | ||
|
nuno-vieira marked this conversation as resolved.
Outdated
|
||
| /// The (potentially rewritten/signed) URL to load. | ||
| public var url: URL | ||
| /// Optional HTTP headers to include in the load request. | ||
| public var headers: [String: String]? | ||
| /// Optional caching key. If nil, the loader defaults to using the URL string. | ||
| public var cachingKey: String? | ||
|
|
||
| public init(url: URL, headers: [String: String]? = nil, cachingKey: String? = nil) { | ||
| self.url = url | ||
| self.headers = headers | ||
| self.cachingKey = cachingKey | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.