ios - AWS S3 分段上传在后台太慢 - iOS

标签 ios swift amazon-s3 awss3transfermanager awss3transferutility

我在我的 iOS 应用程序中使用 AWS S3TransferUtility 的 uploadUsingMultipart(fileURL, bucket, ...) 函数将视频文件上传到 S3 存储桶。只要应用程序处于前台,上传就会非常快。但是,一旦应用程序进入后台,上传过程就会非常缓慢,并且需要花费太多时间才能完成。

例如,我在互联网连接上使用 100 MB 的文件进行了测试,上传速度为 10 Mbps,当应用程序在前台时使用 multipart 上传需要 35 秒,但上传同一文件需要 14 分 40 秒当应用程序在后台时使用 multipart。

有没有办法在后台加快上传过程?

最佳答案

由于答案很长,我更新为答案。

根据 Apple 关于后台执行的文档,它说:

Suppose if you are running a process and in between you press the home button and your app goes to the background, then your app should get some time to finish what it was doing or at least in most cases it should be able to save any important data. This is where you are requesting the os for the background execution.

Normally the OS will give upto 3 minutes(180 seconds) to complete the task . This is just a general observation. The time can be greater than or less than 3 minutes.This is not given in the official documentation.

如果您在后台运行一段时间后未调用 endBackgroundTask(),您的应用将被终止。您最终会丢失上传内容。

想法:

  1. 如果您的任务没有在分配的时间(3 分钟)内完成,您可以向用户发送一些本地通知“打开您的应用程序以恢复上传”
  2. 可以批量上传(dropbox使用分 block 器上传或更新数据)
  3. 如果你看一下 whatsapp,谷歌照片。当您在上传时进入后台时,它会提醒您。
  4. 上传前,检查数据是否庞大,然后提醒用户。如果接受它上传它。
  5. 可以选择仅在 wifi 上上传

警告:无法在后台执行无限或长时间运行的任务

关于ios - AWS S3 分段上传在后台太慢 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54415762/

相关文章:

amazon-web-services - fuse : device not found, 在 docker 容器上安装 s3 存储桶时首先尝试 'modprobe fuse'

amazon-web-services - 如何使用 PHP 和 MySQL 为 Amazon EC2 网站设置基本的 Auto Scaling

swift - Firestore - UITableViewCell 内的 UISlider

swift - 为什么编程语言(例如 Swift)不使用最快的可用排序——桶排序?

javascript - AWS s3重定向到另一个s3存储桶

ios - 如何将测试 RevMobAds 转换为生产

ios - UITableView:如何在 viewForHeaderInSection 中获取 heightForHeaderInSection

ios - Xcode 8.1 和 iOS 10.1.1 无法构建

ios - ARC 的 CoreAnimation 内存问题

ios - UIViewController 子类上的 Swift 可选或隐式属性