From b2bb665c7be33c3b19cf854755218975b70146fc Mon Sep 17 00:00:00 2001 From: ThibaultBee Date: Tue, 14 Dec 2021 10:37:12 +0000 Subject: [PATCH] feat(swift5): Use a protocol for progressive upload session --- .openapi-generator/FILES | 1 + ApiVideoClient.podspec | 4 ++-- CHANGELOG.md | 3 +++ README.md | 4 ++-- Sources/APIs/VideosAPI.swift | 4 ++-- Sources/Upload/ProgressiveUploadSessioning.swift | 9 +++++++++ project.yml | 2 +- 7 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 Sources/Upload/ProgressiveUploadSessioning.swift diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index aa77f57..8f06432 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -91,6 +91,7 @@ Sources/SynchronizedDictionary.swift Sources/Upload/ChunkInputStream.swift Sources/Upload/FileChunksBuilder.swift Sources/Upload/FileReaders.swift +Sources/Upload/ProgressiveUploadSessioning.swift docs/AccessToken.md docs/AuthenticatePayload.md docs/AuthenticationAPI.md diff --git a/ApiVideoClient.podspec b/ApiVideoClient.podspec index c82bac0..0abb865 100644 --- a/ApiVideoClient.podspec +++ b/ApiVideoClient.podspec @@ -4,8 +4,8 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.12' s.tvos.deployment_target = '10.0' s.watchos.deployment_target = '3.0' - s.version = '0.1.0' - s.source = { :git => 'https://github.com/apivideo/api.video-ios-client', :tag => 'v0.1.0' } + s.version = '0.1.1' + s.source = { :git => 'https://github.com/apivideo/api.video-ios-client', :tag => 'v0.1.1' } s.authors = { 'Ecosystem Team' => 'ecosystem@api.video' } s.license = { :type => 'MIT' } s.homepage = 'https://docs.api.video' diff --git a/CHANGELOG.md b/CHANGELOG.md index 76cf61a..6d9f47e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog All changes to this project will be documented in this file. +## [0.1.1] - 2021-12-14 +- Add a protocol for progressive upload session + ## [0.1.0] - 2021-12-06 - Initial release diff --git a/README.md b/README.md index ef0e6ae..b1602bb 100644 --- a/README.md +++ b/README.md @@ -41,14 +41,14 @@ api.video's iOS client streamlines the coding process. Chunking files is handled Specify it in your `Cartfile`: ``` -github "apivideo/api.video-ios-client" ~> 0.1.0 +github "apivideo/api.video-ios-client" ~> 0.1.1 ``` Run `carthage update` ### CocoaPods -Add `pod 'ApiVideoClient', '0.1.0'` in your `Podfile` +Add `pod 'ApiVideoClient', '0.1.1'` in your `Podfile` Run `pod install` diff --git a/Sources/APIs/VideosAPI.swift b/Sources/APIs/VideosAPI.swift index 58eb793..856e861 100644 --- a/Sources/APIs/VideosAPI.swift +++ b/Sources/APIs/VideosAPI.swift @@ -418,7 +418,7 @@ open class VideosAPI { return ProgressiveUploadWithUploadTokenSession(token: token) } - open class ProgressiveUploadWithUploadTokenSession { + open class ProgressiveUploadWithUploadTokenSession: ProgressiveUploadSessioning { private var partId = 1 private var fileReader = FilePartsReader() private var videoId: String? = nil @@ -659,7 +659,7 @@ open class VideosAPI { return ProgressiveUploadSession(videoId: videoId) } - open class ProgressiveUploadSession { + open class ProgressiveUploadSession: ProgressiveUploadSessioning { private var partId = 1 private var fileReader = FilePartsReader() diff --git a/Sources/Upload/ProgressiveUploadSessioning.swift b/Sources/Upload/ProgressiveUploadSessioning.swift new file mode 100644 index 0000000..fa2e9f9 --- /dev/null +++ b/Sources/Upload/ProgressiveUploadSessioning.swift @@ -0,0 +1,9 @@ +// ProgressiveUploadSessioning.swift +// + +import Foundation + +protocol ProgressiveUploadSessioning { + func uploadPart(file: URL, onProgressReady: ((Progress) -> Void)?, apiResponseQueue: DispatchQueue, completion: @escaping ((_ data: Video?, _ error: Error?) -> Void)) -> URLSessionTask? + func uploadLastPart(file: URL, onProgressReady: ((Progress) -> Void)?, apiResponseQueue: DispatchQueue, completion: @escaping ((_ data: Video?, _ error: Error?) -> Void)) -> URLSessionTask? +} \ No newline at end of file diff --git a/project.yml b/project.yml index 40e4992..4fed545 100644 --- a/project.yml +++ b/project.yml @@ -7,7 +7,7 @@ targets: sources: [Sources] info: path: ./Info.plist - version: 0.1.0 + version: 0.1.1 settings: APPLICATION_EXTENSION_API_ONLY: true scheme: {}