Skip to content

Remove Alamofire Dependency #1

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 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
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
8 changes: 1 addition & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(
url: "https://github.com/Alamofire/Alamofire.git",
.upToNextMajor(from: "5.6.1")
),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "MuxUploadSDK",
dependencies: [
"Alamofire",
]
dependencies: [ ]
),
.testTarget(
name: "MuxUploadSDKTests",
Expand Down
6 changes: 2 additions & 4 deletions Sources/MuxUploadSDK/Upload/ChunkWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import Alamofire

/// Uploads a single chunk. Starts an internal Task on creation, which you can get with ``getTask``
/// This class takes care of retries and backoff on a per-chunk basis
Expand All @@ -20,7 +19,6 @@ class ChunkWorker {
let fileMIMEType: String

private var chunkStartTime: TimeInterval? = nil
private var uploadRequest: UploadRequest? = nil
private var lastSeenUpdate: Update = Update(progress: Progress(totalUnitCount: 10), bytesSinceLastUpdate: 0, chunkStartTime: 0, eventTime: 0)
private var progressDelegate: ProgressHandler?

Expand Down Expand Up @@ -183,8 +181,8 @@ fileprivate actor ChunkActor {
let contentRangeValue = "bytes \(chunk.startByte)-\(chunk.endByte - 1)/\(chunk.totalFileSize)"
var request = URLRequest(url: uploadURL)
request.httpMethod = "PUT"
request.headers.add(HTTPHeader(name: "Content-Type", value: fileMIMEType))
request.headers.add(HTTPHeader(name: "Content-Range", value: contentRangeValue))
request.setValue(fileMIMEType, forHTTPHeaderField: "Content-Type")
request.setValue(contentRangeValue, forHTTPHeaderField: "Content-Range")

let (_, response) = try await urlSession.upload(for: request, from: chunk.chunkData)
return response
Expand Down

This file was deleted.