【问题标题】:FineUploader onProgress() callback does not work for AndroidFineUploader onProgress() 回调不适用于 Android
【发布时间】:2013-07-27 19:27:10
【问题描述】:

Fine Uploader 的 onProgress() 回调在 Android 设备中不起作用。这是我的代码:

onProgress: function(id, fileName, loaded, total)
{
    //alert('debug'); this alert shows after download is completer
    if (loaded < total) {
        progress = '"' + fileName + '" uploaded ' + Math.round(loaded / total*100) +'%';                                                              
        $('#progress').html(progress);
    }
    else {
        $('#progress').html('saving');
    }
}

onProgress() 在上传完成后被调用。可能是什么问题以及如何解决? 在official docs 中它说:onProgress(String id, String name, int uploadedBytes, int totalBytes) - called during the upload, as it progresses. Only used by the XHR/ajax uploader.

【问题讨论】:

  • 什么版本的安卓?
  • @RayNicholus Android 4.0.4
  • 所有文件都会发生这种情况,还是只发生小文件?
  • @RayNicholus 我已经测试了 4 MB。我的连接速度很慢,可以注意到它,其他回调运行良好。
  • @RayNicholus 在这里我已经发布了我的工作代码stackoverflow.com/questions/17880719/…

标签: javascript web-applications fine-uploader


【解决方案1】:

经过一番挖掘,我确定——在撰写本文时——Android 4.0.4 的普通浏览器确实完全支持XMLHttpRequest specification。具体来说,XMLHttpRequest 对象不会触发ProgressEvents,这对于确定当前上传文件的进度至关重要。

我尝试通过多种方式将事件处理程序绑定到onprogress 事件,甚至遵循Mozilla Developer Network article,但无济于事。

onprogress 事件在 Android 版 Chrome 上正确触发。

我已提交an issue in our tracker here。希望找到解决方法,或者谷歌等。解决这个问题。

如果您对解决方法有任何建议,请随时分享

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-07
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    • 2017-02-02
    相关资源
    最近更新 更多