Instance Method インスタンスメソッド

urlSession(_:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:)

Periodically informs the delegate of the progress of sending body content to the server. 定期的に委任先に、ボディ内容のサーバへの送信の進捗を告知します。

Declaration 宣言

optional func urlSession(_ session: URLSession, 
                    task: URLSessionTask, 
         didSendBodyData bytesSent: Int64, 
          totalBytesSent: Int64, 
totalBytesExpectedToSend: Int64)

Parameters パラメータ

session

The session containing the data task. データタスクを含んでいるセッション。

task

The data task. データタスク。

bytesSent

The number of bytes sent since the last time this delegate method was called. この委任先メソッドが呼び出された最後の時から送信されたバイト数。

totalBytesSent

The total number of bytes sent so far. これまで送信されたバイトの総数。

totalBytesExpectedToSend

The expected length of the body data. The URL loading system can determine the length of the upload data in three ways: ボディデータの予想される長さ。URLローディングシステムは、アップロードデータの長さを3つの方法で決定できます:

  • From the length of the NSData object provided as the upload body. アップロードボディとして提供されたNSDataオブジェクトの長さから。

  • From the length of the file on disk provided as the upload body of an upload task (not a download task). アップロードタスク(ダウンロードタスクでなく)のアップロードボディとして提供されたディスク上のファイルの長さから。

  • From the Content-Length in the request object, if you explicitly set it. リクエストオブジェクトの中のContent-Lengthから、もしあなたが明示的にそれを設定したならば。

Otherwise, the value is NSURLSessionTransferSizeUnknown (-1) if you provided a stream or body data object, or zero (0) if you did not. そうでなければ、値はNSURLSessionTransferSizeUnknown-1)です、もしあなたがストリームまたはボディデータオブジェクトを提供するならば、またはゼロ(0)もしあなたがそうしなかったならば。

Discussion 議論

The totalBytesSent and totalBytesExpectedToSend parameters are also available as URLSessionTask properties countOfBytesSent and countOfBytesExpectedToSend. Or, since URLSessionTask supports ProgressReporting, you can use the task’s progress property instead, which may be more convenient. totalBytesSentおよびtotalBytesExpectedToSendパラメータはまた、URLSessionTaskのプロパティcountOfBytesSentおよびcountOfBytesExpectedToSendとして利用可能です。または、URLSessionTaskProgressReportingをサポートすることから、あなたはタスクのもつprogressプロパティを代わりに使用できます、それはより便利かもしれません。

See Also 参照

Working with Upload Tasks アップロードタスクを扱う