-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FileCDN class enable generating signedURL's in File Attachments (#…
…620)
- Loading branch information
Showing
4 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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,32 @@ | ||
// | ||
// Copyright © 2024 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import StreamChat | ||
|
||
/// A protocol the video preview uploader implementation must conform to. | ||
public protocol FileCDN: AnyObject { | ||
/// Prepare and return an adjusted or signed `URL` for the given file `URL` | ||
/// This function can be used to intercept an unsigned URL and return a valid signed URL | ||
/// - Parameters: | ||
/// - url: A file URL. | ||
/// - completion: A completion that is called when an adjusted URL is ready to be provided. | ||
func adjustedURL( | ||
for url: URL, | ||
completion: @escaping ((Result<URL, Error>) -> Void) | ||
) | ||
} | ||
|
||
/// The `DefaultFileCDN` implemenation used by default. | ||
public final class DefaultFileCDN: FileCDN { | ||
|
||
// Initializer required for subclasses | ||
public init() { | ||
// Public init. | ||
} | ||
|
||
public func adjustedURL(for url: URL, completion: @escaping ((Result<URL, any Error>) -> Void)) { | ||
completion(.success(url)) | ||
} | ||
} |
This file contains 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