我需要在每次上传之前和之后用其他HTTP POST 请求在后台上传文件。
以前我使用 beginBackgroundTaskWithExpirationHandler 这是完美的工作,直到iOS 6,但从IOS 7只限于约180秒,这是一个问题。
我已阅读文档关于NSURLSession在我们有后台传输服务。但是这个问题只允许在后台上传和下载。它不允许我在每次上传后在后台发出POST请求。
那么有什么办法可以让POST请求和后台上传一起吗? $ b
任何提示正确的方向将是高度赞赏。
解决方案我认为你可以使用NSURLSessionDownloadTask来发送POST。IMO,下载任务并不意味着它被用于下载。这意味着您的POST请求(json / xml)的响应将被下载到本地文件。然后你可以打开这个文件并解析它来获得请求。
如果你想要的话你甚至可以使用NSURLSessionDownloadTask来上传文件到S3。而s3响应将被下载到本地文件中。
有关更多信息,请参阅Apple开发人员论坛中的此问题devforums.apple/thread/210515?tstart=0
I need to upload files in the background with other HTTP POST requests before and after each upload.
Previously I was using beginBackgroundTaskWithExpirationHandler which was working perfectly till iOS 6 but from IOS 7 it is restricted for approx 180 seconds only which is a concern.
I have read the documents regarding NSURLSession were in we have Background transfer service. But the problem with this is it only allows upload and download in background. It doesn't allow me to make POST request after every upload in the background.
So is there any way to make the POST request along with the background uploads?
Any hint in the right direction would be highly appreciated.
解决方案I think you can use NSURLSessionDownloadTask to send a POST.
IMO, download task doesn't mean it is used for download. it means the response of your POST request (json/xml) will be downloaded to a local file. Then you can open that file and parse it to get the request.
if you want you can even use a NSURLSessionDownloadTask to upload files to S3. and the s3 response will be 'downloaded' to a local file..
for more information, see this question in the apple developer forum devforums.apple/thread/210515?tstart=0
更多推荐
iOS 7后台上传和POST请求
发布评论