NSURLSession and stream upload in background

后端 未结 4 1662
遇见更好的自我
遇见更好的自我 2021-01-02 10:19

I have some problems with using NSURLSession to upload photos from Asset Library to the server.

At first NSURLSession doesn\'t support stre

4条回答
  •  攒了一身酷
    2021-01-02 10:50

    A clean workaround will be to create a NSOperation which will copy the file from the asset library to your temporary folder using NSStream, so you won't get a crash in case of a huge file, when the operation completes you schedule a upload of that temporary file, when the upload finishes you delete it.

    In my case, i need to send the file in multipart format so the creation of the temporary file is necessary but i encounter a problem in uploading large files, more then 2 Gb, example movies over 20 minutes.

提交回复
热议问题