How to work with large file uploads in ios?

后端 未结 2 862
再見小時候
再見小時候 2021-01-02 09:51

My app requires upload of video files from users phone which will then be processed on server. THe problem is the size of the file can go to 200 MB plus and the user won\'t

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-02 10:19

    You should use a background session configuration instead if a default session configuration. This ensures that your data transfer will continue in the background once the user has exited your app.

    Of course, this is correct as long as the user has background fetching enabled for your app in the Settings app of the device.

    Be sure to enable the Background fetch capability on your project settings:


    (source: migueldiazrubio.com)


    (source: migueldiazrubio.com)

    Then implement the application:handleEventsForBackgroundURLSession:completionHandler: in your App Delegate to be informed when the data transfer ends and do whatever you need to do (UI update…) inside your app with the received/sent file. Don't forget to call the completionHandler to inform the system that you have ended your tasks. iOS then will take a screenshot of the active screen of your app and update the one in the iOS 7 multitasking screen.

提交回复
热议问题