A Swift SDK for WeTransfer’s public API
For your API key and additional info please visit our developer portal.
- Create and upload a transfer from a single method call
- Seperate methods for each seperate step in the process
- Cancelling and resuming uploads
- iOS 9.0+ / macOS 10.10+
- Xcode 9.4+
- Swift 4.2+
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate WeTransfer into your Xcode project using Carthage, specify it in your Cartfile
:
github "WeTransfer/WeTransfer-Swift-SDK" ~> 2.0
Run carthage update
to build the framework and drag the built WeTransfer.framework
into your Xcode project.
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler.
Once you have your Swift package set up, adding the WeTransfer SDK as a dependency is as easy as adding it to the dependencies
value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/Alamofire/WeTransfer-Swift-SDK.git", from: "2.0")
]
Note: Running swift test
doesn’t work currently as Swift packages can’t have resources in their test targets.
CocoaPods is a dependency manager for Cocoa projects.
To integrate the WeTransfer Swift SDK into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'WeTransfer-Swift-SDK', '>= 2.0'
end
Then, run the following command:
$ pod install
Before the SDK can do anything with the WeTransfer API, it needs to be authenticated with an API key. You can create an API key at the developer portal
- Configure the client Create a configuration with your API key
let configuration = WeTransfer.Configuration(apiKey: "YOUR_API_KEY")
WeTransfer.configure(with: configuration)
- Uploading files with a new transfer
Creating a transfer and uploading files to it can be done with one method call,
WeTransfer.uploadTransfer
. Files in the SDK are represented byFile
objects, but this convenience methods expects an array ofURL
s pointing to files on your device. In thestateChanged
closure you’re updated about things like the upload progress or whether is has completed or failed
let files = [...]
WeTransfer.uploadTransfer(saying: "Transfer Name", containing: files) { state in
switch state {
case .created(let transfer):
print("Transfer created")
case .uploading(let progress):
print("Transfer uploading")
case .completed(let transfer):
print("Upload completed")
case .failed(let error):
XCTFail("Transfer failed: \(error.localizedDescription)")
}
}
We recommend checking out the contribution guide for a full run-through of how to get started, but in short:
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
The WeTransfer Swift SDK is available under the MIT license. See the LICENSE file for more info.
Everyone interacting in the WeTransfer Swift SDK project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct