Get Updates By E-mail 

Article Written By:
Johann Dowa

Open Source Swift Library For Uploads/Downloads With Concurrency, Background Support And More

  •  
  •  
  •  
  •  
  •  

I’ve mentioned a number of libraries that make networking with Swift easier such as the popular AlamoFire library.

Here’s a Swift based library submitted ny nghialv that provides a nice clean syntax for file uploading and downloading with a number of neat features called Transporter.

With Transporter you can upload/download concurrently and sequentially in the background, pause/resume transfers, and support for progress tracking.

This code snippet from the readme shows some example uses of Transport:

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()

You can find Transporter on Github here.

A nice library for working with downloads.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments