From d00607d55e899ae45e721514ea8a19772c8877de Mon Sep 17 00:00:00 2001 From: ThibaultBee <37510686+ThibaultBee@users.noreply.github.com> Date: Tue, 28 Nov 2023 12:08:09 +0100 Subject: [PATCH] wip(client): add support for background upload --- .../xcshareddata/swiftpm/Package.resolved | 9 -- Sources/APIs.swift | 2 + Sources/APIs/VideosAPI.swift | 6 +- Sources/FileHelper.swift | 29 +++++ Sources/URLSessionImplementations.swift | 114 ++++++++++++++---- 5 files changed, 126 insertions(+), 34 deletions(-) create mode 100644 Sources/FileHelper.swift diff --git a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 969e0eb..a6aeb70 100644 --- a/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,14 +1,5 @@ { "pins" : [ - { - "identity" : "alamofire", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Alamofire/Alamofire", - "state" : { - "revision" : "d120af1e8638c7da36c8481fd61a66c0c08dc4fc", - "version" : "5.4.4" - } - }, { "identity" : "anycodable", "kind" : "remoteSourceControl", diff --git a/Sources/APIs.swift b/Sources/APIs.swift index c2dbff2..e63c6cf 100644 --- a/Sources/APIs.swift +++ b/Sources/APIs.swift @@ -14,6 +14,7 @@ public class ApiVideoClient { internal static var requestBuilderFactory: RequestBuilderFactory = URLSessionRequestBuilderFactory() public static var apiResponseQueue: DispatchQueue = .main public static var timeout: TimeInterval = 60 + public static var backgroundIdentifier: String = "video.api.upload.background" internal static var customHeaders:[String: String] { var headers = defaultHeaders if let apiKey = apiKey { @@ -135,4 +136,5 @@ open class RequestBuilder { public protocol RequestBuilderFactory { func getNonDecodableBuilder() -> RequestBuilder.Type func getBuilder() -> RequestBuilder.Type + func getBackgroundBuilder() -> RequestBuilder.Type } diff --git a/Sources/APIs/VideosAPI.swift b/Sources/APIs/VideosAPI.swift index 5bcd506..76e77d6 100644 --- a/Sources/APIs/VideosAPI.swift +++ b/Sources/APIs/VideosAPI.swift @@ -190,7 +190,7 @@ The latter allows you to split a video source into X chunks and send those chunk let localVariableHeaderParameters = APIHelper.rejectNilHeaders(localVariableNillableHeaders) - let localVariableRequestBuilder: RequestBuilder