iOS 7后台上传和POST请求

编程入门 行业动态 更新时间:2024-10-27 04:29:01
本文介绍了iOS 7后台上传和POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要在每次上传之前和之后用其他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请求

本文发布于:2023-11-26 05:47:16,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:后台   上传   iOS   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!