Created
March 4, 2026 12:00
-
-
Save jacobsapps/ace04787d132ed44cc8a8cb209f06f70 to your computer and use it in GitHub Desktop.
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
| func resumableUpload(videoURL: URL, sessionId: String, fileSize: Int64) async throws { | |
| var offset = max( | |
| startResponse.nextOffset, | |
| await offsetStore.offset(for: sessionId) | |
| ) | |
| while offset < fileSize { | |
| do { | |
| let chunkFile = try temporaryChunkFile( | |
| sourceVideoURL: videoURL, offset: offset, length: Int(chunkSize) | |
| ) | |
| let request = makeChunkRequest( | |
| sessionId: sessionId, offset: offset, totalBytes: fileSize | |
| ) | |
| _ = try await session.data(for: request) | |
| offset += chunkFile.byteCount | |
| await offsetStore.set(offset: offset, for: sessionId) | |
| } catch { | |
| offset = try await fetchRemoteOffset(sessionId: sessionId) | |
| await offsetStore.set(offset: offset, for: sessionId) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment