This project is now archived as the Public WeTransfer API is no longer maintained.
A Swift SDK for WeTransfer’s public API
For your API key and additional info please visit our developer portal.
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
let configuration = WeTransfer.Configuration(apiKey: "YOUR_API_KEY")
WeTransfer.configure(with: configuration)
WeTransfer.uploadTransfer
. Files in the SDK are represented by File
objects, but this convenience methods expects an array of URL
s 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 failedlet files = [...]
WeTransfer.uploadTransfer(sayinsrc="https://raw.github.com/WeTransfer/WeTransfer-Swift-SDK/master/ransfer 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)")
}
}
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.
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.
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
link |
Stars: 39 |
Last commit: 3 years ago |
Updated SDK to support v2 of the WeTransfer Public API which now distinguishes transfers and boards. Read more about it here.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics