Skip to content

muxinc/swift-upload-sdk

Repository files navigation

Mux's Swift Upload SDK

This SDK makes it easy to upload videos to Mux from an iOS app. It handles large files by breaking them into chunks and uploads each chunk individually. Each file that gets uploaded will get sent to an upload URL created by a backend server. Do not include credentials to create an upload URL from an app.

Usage

To use this SDK, you must first add it as a dependency. The Mux Swift Upload SDK for iOS is available on SPM.

Server-Side: Create a Direct Upload

To start an upload, you must first create an upload URL. Then, pass return that direct-upload PUT URL to your app, so the app can begin the upload process

App-Side: Add Package Dependency

Add our SDK as a package dependency to your XCode project with the following steps. Our repository URL (for the 'search' field in the upper corner) is https://github.com/muxinc/swift-upload-sdk

App-Side: Start an Upload

To start an upload, you must first create an upload URL. Then, pass the upload URL and the file to be uploaded into the SDK.

let upload = MuxUpload(
    uploadURL: myMuxUploadURL,
    videoFileURL: myVideoFileURL,
)

upload.progressHandler = { state in
    self.uploadScreenState = .uploading(state)
}

upload.resultHandler = { result in
    switch result {
    case .success(let success):
        self.uploadScreenState = .done(success)
        self.upload = nil
        NSLog("Upload Success!")
    case .failure(let error):
        self.uploadScreenState = .failure(error)
        NSLog("!! Upload error: \(error.localizedDescription)")
    }
}

self.upload = upload
upload.start()

A simple example usage can be found in our Test App

Development

This SDK is a swift package that can be opened by xcode. To edit this SDK, clone it and open the root folder in Xcode.

This SDK has a sample/test app in the TestApp/ folder. You can run/edit the sample app by opening apps/Test App/Upload Test App.xcodeproj

About

Mux's Video Upload SDK for iOS. The Swift equivalent of UpChunk.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 8