• Stars
    star
    452
  • Rank 96,761 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tiny library makes uploading and downloading easier

Platform Language License Issues

Features

  • uploading/downloading multiple files concurrently or sequentially
    • grouping tasks with awesome custom operators (||| and -->)
  • supports background uploading/downloading
  • supports progress tracking (single task and group of tasks)
  • enable to resume, pause, cancel, retry the task
  • header configurable
  • request parameters configurable

Quick example

let path = NSBundle.mainBundle().pathForResource("bigfile", ofType: "zip")
let fileUrl = NSURL(fileURLWithPath: path!)!

let task = UploadTask(url: "http://server.com", file: fileUrl)
	.progress { sent, total in
		let per = Double(sent) / Double(total)
		println("uploading: \(per)")
	}
	.completed { response, json, error in
		println("completed")
	}

 
 Transporter.add(task1 ||| task2 ||| task3)                     // concurrent tasks
            .progress { bytes, total in
                let per = Double(bytes) / Double(total)
                println("concurrent tasks: \(per)")
            }
            .completed { alltasks in
                println("task1, task2, task3: completed")
            }
            .add(task4 --> task5 --> task6)                       // sequential tasks 
            .progress { bytes, total in
                println("serial tasks")
            }
            .resume()

Usage

// downloading task

let task = DownloadTask(url: downloadUrl, destination: des)
	.progress { bytes, total in
		let per = Double(bytes) / Double(total)
		println("downloading: \(per)")
	}
	.completed { response, _, error in
		println("completed")
	}


// uploading task
// upload types: File, Data, Stream

let task = UploadTask(url: "http://server.com", data: uploadData)
	.progress { sent, total in
		let per = Double(sent) / Double(total)
		println("uploading: \(per)")
	}
	.completed { response, json, error in
		println("completed")
	}


// using  `|||`  operator to create a group of concurrent tasks

Transporter.add(task1 ||| task2 ||| task3)

// using  `-->`  operator to create a group of sequential tasks

Transporter.add(task1 --> task2 --> task3)


// task

task.headers = ["key": "value"]
task.params = ["key": "value"]
task.pause()
task.cancel()
task.retry

// background handling
// add the following method in the app delegate

func application(application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: () -> Void) {
	Transporter.handleEventsForBackgroundURLSection(identifier, completionHandler: completionHandler)
}


// Transporter configurations

Transporter.headers = [key: value]
Transporter.timeoutIntervalForRequest = 30.0
Transporter.timeoutIntervalForResource = 24 * 60 * 60.0
Transporter.HTTPMaximumconnectionsPerHost = 5
			

Installation

  • Installation with CocoaPods
pod 'TransporterSwift', '0.1.1'

Then run the following command:

pod install
  • Copying all the files into your project
  • Using submodule

Todo

  • retry, pause, cancel
  • validation

Requirements

  • iOS 8.0+
  • Xcode 6.1

License

Transporter is released under the MIT license. See LICENSE for details.

More Repositories

1

MaterialKit

Material design components for iOS written in Swift
Swift
2,504
star
2

promviz

Visualize the traffic of your clusters in realtime from Prometheus data
Go
955
star
3

Hakuba

🌸 Cellmodel-driven tableview manager
Swift
474
star
4

Net

Http Request wrapper written in Swift
Swift
302
star
5

Sapporo

Cellmodel-driven collectionview manager
Swift
246
star
6

Future

Swift µframework providing Future<T, Error>
Swift
122
star
7

GCD

A wrapper of Grand Central Dispatch written in Swift
Swift
72
star
8

Try

Swift µframework providing Try<T>
Swift
32
star
9

openGL-tankgame

A simple 3D game using openGL
C++
23
star
10

TVDataSource

datasource class for uitableview
Objective-C
17
star
11

gamegl

the bottom part of puzzle dragon game using OpenglES (without any framework)
Objective-C
14
star
12

iBall

iPhone, iPad間のバトルゲーム (OpenGLES)
C
6
star
13

VersionTracker

Tracking the app version
Swift
4
star
14

clibs

Central repository containing C libraries for testing
C
3
star
15

opencv-optical-flow

OpenCV, Python
Python
3
star
16

xcode_project_templates

xcode project templates
Objective-C
3
star
17

Kinect-ARToolKit

some simple examples of using Kinect (OpenNI) and ARToolKit
C++
2
star
18

vlcamera

vlcamera app
Objective-C
2
star
19

funnytext

render text in some shapes, change the position and orientation of each character
Objective-C
2
star
20

opencv_ios

opencv (face, eyes... tracking)
1
star
21

nghialv.github.com

my blog
HTML
1
star
22

flex-bison-cpp

a simple example of flex, bison
C++
1
star
23

tomojisho

a facebook game which looks like a dictionary for your friends. Through this game, you can review the information of your friends
PHP
1
star
24

rubyss

ruby shell script
Ruby
1
star