English | 中文
SwiftyUploader is a file upload server for iOS platform implemented based on SwiftNIO. If your iOS App needs to upload files from a computer or another phone to your App, you can use this library to quickly implement this feature. The Web page part of SwiftyUploader uses the code from GCDWebUploader.
- iOS 14.0+
- Xcode 14.3
- Swift 5.8
You can use The Swift Package Manager for integration. Or you can enter https://github.com/kejinlu/SwiftyUploader.git
in the dependency window in Xcode to add dependencies, or directly use local dependencies for testing.
// swift-tools-version:5.8
import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
dependencies: [
.package(url: "https://github.com/kejinlu/SwiftyUploader.git", from: "0.0.1"),
]
)
Then run swift build
whenever you get prepared.
Starting the server:
let uploader = SwiftyUploader()
DispatchQueue.global().async {
do {
try uploader.run()
} catch {
DispatchQueue.main.async {
print("Failed to start server: \(error)")
}
return
}
}
Stopping the server:
DispatchQueue.global().async {
do {
try uploader.stop()
} catch {
DispatchQueue.main.async {
print("Failed to stop server: \(error)")
}
return
}
}
If you need web page support for international languages, you need to add the following settings in the app's info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
</dict>
</plist>