简体   繁体   English

HTML5和Javascript,iPhone文件上传,防止手机进入睡眠状态

[英]HTML5 & Javascript, iPhone File Upload, Preventing phone from going to sleep

Use-case 用例

  1. HTML5 WebSite @ iPhone is used to upload Big Video files ( from the gallery ) HTML5网站@ iPhone用于上传Big Video文件(来自库)
  2. Big files take considerable time to upload 大文件需要花费大量时间才能上传
  3. iPhone get into sleep mode within ~15 seconds iPhone在约15秒内进入睡眠模式
  4. While in sleep mode formdata/multipart upload is paused 在睡眠模式下,formdata /分段上传已暂停

Having the above in mind, it is not practical to upload big files using an iPhone website. 考虑到以上几点,使用iPhone网站上传大文件是不切实际的。

I must have this implemented using a WebSite. 我必须使用WebSite来实现。

Using a WebSite ( and not an App ) Is there any way to 使用网站(而非应用程序)是否可以

  1. Prevent the phone from going to sleep while uploading 上载时防止手机进入睡眠状态
  2. Keep JavaScript/Upload running while the phone is sleeping 在手机处于休眠状态时保持JavaScript /上传运行

Any help will be appreciated 任何帮助将不胜感激

UPDATE: This article appears to be more relevant. 更新: 本文似乎更相关。

You should chunk the video and hash each chunk using the HTML5 File API . 您应该对视频进行分块,并使用HTML5 File API对每个块进行哈希处理。 Mobile devices have a lot of errors during transmissions. 移动设备在传输过程中存在很多错误。 If a chunk fails, you'll need to request it again. 如果块失败,则需要再次请求。 This may not seem like an issue if you're going over SSL or TLS, however, it actually is an issue. 如果您要通过SSL或TLS,这似乎不是问题,但是,这实际上是一个问题。 The failure rates are really high if you don't chunk the video (because it has to start all over again and the probability of failure during such a large file is quite high). 如果您不对视频进行分块,则故障率确实很高(因为视频必须重新开始,并且在这么大的文件中发生故障的可能性非常高)。

Also, take a peek at this video . 另外,请观看此视频 It will further explain some details of transmission patterns of radios in mobile devices. 它将进一步解释移动设备中无线电的传输模式的一些细节。 There are further references at the end of the talk for even more details. 谈话结束时还有更多参考资料,以提供更多详细信息。

As for how to bypass the UIWebView behaviour, you may want to try intercepting the HTTP request and writing Objective C code to manage the uploading. 至于如何绕过UIWebView行为,您可能想尝试拦截HTTP请求并编写Objective C代码来管理上载。 See this article for implementation details. 有关实现的详细信息,请参见本文

Lastly, I'm not sure how successful you'll be with a UIWebView only implementation (ie. not writing Objective C). 最后,我不确定使用UIWebView的实现是否会成功(即,不编写Objective C)。 UIWebView seems to be aggressive (and inconsistent) about how much memory it lets you consume before it forcibly closes your web page. UIWebView在强制关闭网页之前让您消耗多少内存似乎有些激进(且不一致)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM