Create and upload a transfer from a single method call
Seperate methods for each seperate step in the process
Cancelling and resuming uploads
Requirements
iOS 9.0+ / macOS 10.10+
Xcode 9.4+
Swift 4.2+
Installation
Carthage
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.
Swift Package Manager
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.
Note: Running swift test doesn’t work currently as Swift packages can’t have resources in their test targets.
Cocoapods
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
Usage
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 by File objects, but this convenience methods expects an array of URLs pointing to files on your device.
In the stateChanged 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)")
}
}
Sample Application
Included with the project is a neat little sample application that shows a possible use case for the SDK. It allows for photos and videos to be added to a transfer and shows the upload progress for the whole transfer, aAfter which the URL can be shared.
Communication
We recommend checking out the contribution guide for a full run-through of how to get started, but in short:
The WeTransfer Swift SDK is available under the MIT license. See the LICENSE file for more info.
Code of Conduct
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
This project is now archived as the Public WeTransfer API is no longer maintained.
WeTransfer-Swift-SDK
A Swift SDK for WeTransfer’s public API
For your API key and additional info please visit our developer portal.
Features
Requirements
Installation
Carthage
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:
To integrate WeTransfer into your Xcode project using Carthage, specify it in your
Cartfile
:Run
carthage update
to build the framework and drag the builtWeTransfer.framework
into your Xcode project.Swift Package Manager
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 yourPackage.swift
.Swift 4
Note: Running
swift test
doesn’t work currently as Swift packages can’t have resources in their test targets.Cocoapods
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
:Then, run the following command:
Usage
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
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 failedSample Application
Communication
We recommend checking out the contribution guide for a full run-through of how to get started, but in short:
License
The WeTransfer Swift SDK is available under the MIT license. See the LICENSE file for more info.
Code of Conduct
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