SwiftyUploader

0.02

A web based uploader powered by SwiftNIO.
kejinlu/SwiftyUploader

What's New

2023-08-13T14:03:37Z

Implement async calls for running and stopping the server by using DispatchQueue.

SwiftyUploader logo

English | 中文

Overview

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.

SwiftyUploader logo

Usage

Requirements

  • iOS 14.0+
  • Xcode 14.3
  • Swift 5.8

Integration

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.

Code

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>

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

Last updated: Thu Oct 17 2024 23:24:42 GMT-0900 (Hawaii-Aleutian Daylight Time)