View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vídeos

Abrir menu Fechar menu
  • Coleções
  • Todos os vídeos
  • Sobre

Mais vídeos

  • Sobre
  • Código
  • Build robust and resumable file transfers

    Find out how URLSession can help your apps transfer large files and recover from network interruptions. Learn how to pause and resume HTTP file transfers and support resumable uploads, and explore best practices for using URLSession to transfer files even when your app is suspended in the background.

    Capítulos

    • 0:00 - Welcome
    • 2:42 - Explore the resumable downloads protocol in HTTP
    • 4:23 - Pause and resume downloads with URLSession
    • 7:50 - Pause and resume uploads with URLSession
    • 9:45 - Explore the resumable uploads protocol in HTTP
    • 12:46 - Add resumable uploads to SwiftNIO
    • 16:11 - Use background URLSession

    Recursos

    • Building a resumable upload server with SwiftNIO
    • Downloading files in the background
    • URLSession
      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC19

    • Advances in Networking, Part 1
  • Buscar neste vídeo...
    • 4:53 - Pausing and resuming a URLSessionDownloadTask

      let downloadTask = session.downloadTask(with: request)
      downloadTask.resume()
    • 5:21 - Pausing and resuming a URLSessionDownloadTask

      let downloadTask = session.downloadTask(with: request)
      downloadTask.resume()
      
      guard let resumeData = await downloadTask.cancelByProducingResumeData() else {
          // Download cannot be resumed
          return
      }
    • 6:11 - Pausing and resuming a URLSessionDownloadTask

      let downloadTask = session.downloadTask(with: request)
      downloadTask.resume()
      
      guard let resumeData = await downloadTask.cancelByProducingResumeData() else {
          // Download cannot be resumed
          return
      }
      
      let newDownloadTask = session.downloadTask(withResumeData: resumeData)
      newDownloadTask.resume()
    • 6:34 - Retrieving resume data on error

      do {
          let (url, response) = try await session.download(for: request)
      } catch let error as URLError {
          guard let resumeData = error.downloadTaskResumeData else {
              // Download cannot be resumed
              return
          }
      }
    • 8:29 - Pausing and resuming a URLSessionUploadTask

      let uploadTask = session.uploadTask(with: request, fromFile: fileURL)
      uploadTask.resume()
    • 8:37 - Pausing and resuming a URLSessionUploadTask

      let uploadTask = session.uploadTask(with: request, fromFile: fileURL)
      uploadTask.resume()
      
      guard let resumeData = await uploadTask.cancelByProducingResumeData() else {
          // Upload cannot be resumed
          return
      }
    • 8:57 - Pausing and resuming a URLSessionUploadTask

      let uploadTask = session.uploadTask(with: request, fromFile: fileURL)
      uploadTask.resume()
      
      guard let resumeData = await uploadTask.cancelByProducingResumeData() else {
          // Upload cannot be resumed
          return
      }
      
      let newUploadTask = session.uploadTask(withResumeData: resumeData)
      newUploadTask.resume()
    • 9:22 - Retrieving resume data on error

      do {
          let (data, response) = try await session.upload(for: request, fromFile: fileURL)
      } catch let error as URLError {
          guard let resumeData = error.uploadTaskResumeData else {
              // Upload cannot be resumed
              return
          }
      }
    • 13:15 - Before resumable uploads in Swift NIO

      NIOTSListenerBootstrap(group: NIOTSEventLoopGroup())
          .childChannelInitializer { channel in
              channel.configureHTTP2Pipeline(mode: .server) { channel in
                  channel.pipeline.addHandlers([
                      HTTP2FramePayloadToHTTPServerCodec(),
                      ExampleChannelHandler()
                  ])
              }.map { _ in () }
          }
          .tlsOptions(tlsOptions)
    • 14:06 - Add resumable uploads in Swift NIO

      import NIOResumableUpload
      
      let uploadContext = HTTPResumableUploadContext(origin: "https://example.com")
      
      NIOTSListenerBootstrap(group: NIOTSEventLoopGroup())
          .childChannelInitializer { channel in
              channel.configureHTTP2Pipeline(mode: .server) { channel in
                  channel.pipeline.addHandlers([
                      HTTP2FramePayloadToHTTPServerCodec(),
                      HTTPResumableUploadHandler(context: uploadContext, handlers: [
                          ExampleChannelHandler()
                      ])
                  ])
              }.map { _ in () }
          }
          .tlsOptions(tlsOptions)
    • 15:48 - Informational responses in URLSession

      protocol URLSessionTaskDelegate : URLSessionDelegate {
          optional func urlSession(_ session: URLSession, task: URLSessionTask,
                                   didReceiveInformationalResponse response: HTTPURLResponse)
      }
    • 18:19 - Using background URLSession

      // Configuring your background session
      let configuration = URLSessionConfiguration.background(withIdentifier: "com.example.app")
      configuration.isDiscretionary = true
      configuration.allowsConstrainedNetworkAccess = false
      let session = URLSession(configuration: configuration, delegate: self, delegateQueue: nil)
      
      // Configuring your background task
      let backgroundTask = session.uploadTask(with: url, fromFile: fileURL)
      backgroundTask.earliestBeginDate = .now.addingTimeInterval(60 * 60)
      backgroundTask.countOfBytesClientExpectsToSend = 500 * 1024
      backgroundTask.countOfBytesClientExpectsToReceive = 200

Developer Footer

  • Vídeos
  • WWDC23
  • Build robust and resumable file transfers
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines