Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Sources/MuxUploadSDK/Upload/ChunkWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,15 @@ fileprivate actor ChunkActor {
let urlSession: URLSession

func upload() async throws -> URLResponse {
let contentRangeValue = "bytes \(chunk.startByte)-\(chunk.endByte - 1)/\(chunk.totalFileSize)"
let startByte = "\(chunk.startByte)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the subtraction method that reports overflow might be a good alternative here too.

let endByte: String
if chunk.endByte == 0 {
endByte = "0"
} else {
endByte = "\(chunk.endByte - 1)"
}

let contentRangeValue = "bytes \(startByte)-\(endByte)/\(chunk.totalFileSize)"
var request = URLRequest(url: uploadURL)
request.httpMethod = "PUT"
request.setValue("video/*", forHTTPHeaderField: "Content-Type")
Expand Down