<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          TransporterSwift 工具庫

          聯(lián)合創(chuàng)作 · 2023-09-30 23:10

          Transporter 是一個方便上傳和下載的庫。

          特性

          • 支持并發(fā)或者順序上傳或者下載多個文件

          • 支持后臺上傳和下載

          • 支持進程跟蹤 (單個任務(wù)或者任務(wù)組)

          • 支持重置,停止,取消,重試任務(wù)

          • header 可配置

          • 請求參數(shù)可配置

          快速示例

          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)                       // serial tasks 
                      .progress { bytes, total in
                          println("serial tasks")
                      }            .resume()
          

          用法

          // downloading tasklet 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, Streamlet 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")
              }// tasktask.headers = ["key": "value"]
          task.params = ["key": "value"]
          task.pause()
          task.cancel()
          task.retry// background handling// add the following method in the app delegatefunc application(application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: () -> Void) {
              Transporter.handleEventsForBackgroundURLSection(identifier, completionHandler: completionHandler)
          }// Transporter configurationsTransporter.headers = [key: value]
          Transporter.timeoutIntervalForRequest = 30.0Transporter.timeoutIntervalForResource = 24 * 60 * 60.0Transporter.HTTPMaximumconnectionsPerHost = 5
          瀏覽 16
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  中文字幕五码在线 | 国产免费久久 | 久久人妻无码 | 国产精品无套久久久久 | 日韩无码乱伦av 日韩无码视频不卡 |