diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7dd4b89 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,63 @@ +name: Build + +on: [push] + +jobs: + build-swift: + name: Build with swift + runs-on: macos-12 + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: xcode version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '13.4.1' + - name: Build Package with swift + run: swift build + + build-xcodebuild: + name: Build with xcodebuild + runs-on: macos-12 + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: xcode version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '13.4.1' + - name: Set Default Scheme + run: | + scheme_list=$(xcodebuild -list -json | tr -d "\n") + default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['workspace']['schemes'][0]") + echo $default | cat >default + echo Using default scheme: $default + - name: Build Package with xcodebuild + env: + scheme: ${{ 'default' }} + run: | + if [ $scheme = default ]; then scheme=$(cat default); fi + xcodebuild -scheme $scheme -destination 'platform=iOS Simulator,name=iPhone 13' + - name: Build Example + env: + scheme: ${{ 'default' }} + run: | + if [ $scheme = default ]; then scheme=$(cat default); fi + xcodebuild clean build -project Example/Example.xcodeproj -scheme $scheme -sdk iphoneos + + cocoapods: + name: Verify cocopods podspec + needs: [ build-xcodebuild ] + runs-on: macos-12 + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: xcode version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '13.4.1' + - name: Verify cocoapods + run: pod lib lint --allow-warnings diff --git a/ApiVideoClient.podspec b/ApiVideoClient.podspec index 7223055..5a497ff 100644 --- a/ApiVideoClient.podspec +++ b/ApiVideoClient.podspec @@ -5,8 +5,8 @@ Pod::Spec.new do |s| s.tvos.deployment_target = '10.0' # Add back when CocoaPods/CocoaPods#11558 is released #s.watchos.deployment_target = '3.0' - s.version = '1.1.0' - s.source = { :git => 'https://github.com/apivideo/api.video-ios-client', :tag => 'v1.1.0' } + s.version = '1.1.1' + s.source = { :git => 'https://github.com/apivideo/api.video-ios-client', :tag => 'v1.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 6a81ecf..895fc51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog All changes to this project will be documented in this file. +## [1.1.1] - 2022-12-09 +- Fix on upload by chunk and progressive upload. +- Add test on progressive upload. +- Add a `build.yml` CI workflow. + ## [1.1.0] - 2022-12-06 - Refactor upload by chunk and progressive upload. It is now possible to cancel an upload. - Add timeout API diff --git a/README.md b/README.md index 4450ec4..6c9a52e 100644 --- a/README.md +++ b/README.md @@ -42,14 +42,14 @@ api.video's iOS streamlines the coding process. Chunking files is handled for y Specify it in your `Cartfile`: ``` -github "apivideo/api.video-ios-client" ~> 1.1.0 +github "apivideo/api.video-ios-client" ~> 1.1.1 ``` Run `carthage update` ### CocoaPods -Add `pod 'ApiVideoClient', '1.1.0'` in your `Podfile` +Add `pod 'ApiVideoClient', '1.1.1'` in your `Podfile` Run `pod install` diff --git a/Sources/APIs.swift b/Sources/APIs.swift index 30ae1ce..575800d 100644 --- a/Sources/APIs.swift +++ b/Sources/APIs.swift @@ -8,7 +8,7 @@ import Foundation public class ApiVideoClient { public static var apiKey: String? = nil public static var basePath = "https://ws.api.video" - internal static var customHeaders:[String: String] = ["AV-Origin-Client": "ios:1.1.0"] + internal static var customHeaders:[String: String] = ["AV-Origin-Client": "ios:1.1.1"] private static var chunkSize: Int = 50 * 1024 * 1024 internal static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory() internal static var credential = ApiVideoCredential() diff --git a/Sources/APIs/VideosAPI.swift b/Sources/APIs/VideosAPI.swift index 383aab8..b291530 100644 --- a/Sources/APIs/VideosAPI.swift +++ b/Sources/APIs/VideosAPI.swift @@ -86,7 +86,7 @@ open class VideosAPI { /** * Create a progressive upload session * - * - returns: a progressive upload session + - returns: a progressive upload session */ public class func buildProgressiveUploadSession(videoId: String) -> ProgressiveUploadSession { ProgressiveUploadSession(videoId: videoId) @@ -101,6 +101,7 @@ open class VideosAPI { self.videoId = videoId super.init(queueLabel: videoId) } + public func uploadPart(file: URL, onProgressReady: ((Progress) -> Void)? = nil, apiResponseQueue: DispatchQueue = ApiVideoClient.apiResponseQueue, completion: @escaping ((_ data: Video?, _ error: Error?) -> Void)) -> RequestTask { let chunkId = partId @@ -128,13 +129,14 @@ open class VideosAPI { numOfChunks = partId } let requestBuilder = uploadWithRequestBuilder(videoId: videoId, file: file, chunkId: partId, numOfChunks: numOfChunks, onProgressReady: onProgressReady) - execute(requestBuilder, apiResponseQueue: apiResponseQueue, completion: completion) + execute(requestBuilder, apiResponseQueue: apiResponseQueue) { data, error in + completion(data, error) + } return requestBuilder.requestTask } } - /** Upload a video - POST /videos/{videoId}/source @@ -279,7 +281,7 @@ The latter allows you to split a video source into X chunks and send those chunk /** * Create a progressive uploadWithUploadToken session * - * - returns: a progressive uploadWithUploadToken session + - returns: a progressive uploadWithUploadToken session */ public class func buildProgressiveUploadWithUploadTokenSession(token: String) -> ProgressiveUploadWithUploadTokenSession { ProgressiveUploadWithUploadTokenSession(token: token) @@ -295,6 +297,12 @@ The latter allows you to split a video source into X chunks and send those chunk self.token = token super.init(queueLabel: token) } + + override func willExecuteRequestBuilder(requestBuilder: RequestBuilder