【问题标题】:When using netty for a large file upload, how can I get uploaded size while upload is in progress?使用 netty 进行大文件上传时,如何在上传过程中获取上传大小?
【发布时间】:2015-06-13 00:00:12
【问题描述】:

如果我可以在上传过程中获得文件的临时位置,我可以检查大小。但是,我只有在收到 LastHttpContent 并通过 decoder.next() 来获取临时文件位置

有什么方法可以提前获取文件名吗?

我正在运行来自https://github.com/netty/netty/blob/master/example/src/main/java/io/netty/example/http/upload/HttpUploadServerHandler.java的示例代码

如果数据类型是 FileUpload,我想在 writeHttpData 中获取上传百分比

【问题讨论】:

  • 你能添加一些你在做什么的代码吗?
  • @NormanMaurer 感谢您的回复。添加了示例代码参考。
  • 目前,确实,上传期间的文件在处理过程中不可用(因为被decoder.offer(chunk)屏蔽),即使使用 hasNext() 因为它还不可用。
  • 目前,确实,上传过程中的文件在处理过程中不可用(因为被decoder.offer(chunk)decoder.hasNext() ko since not yet available). One could propose an improvement as a combination of sthg close to decoder.isCurrentFileUpload(), decoder.currentFileUpload()`屏蔽,然后将允许检查 fileUpload.length() 以获取当前大小并添加(缺少?)fileUpload.definedSize() 以获取宣布的最终大小(但请注意,例如,如果在 7 位中,可能是 7 位编码文件大小,而不是最终文件大小,所以百分比可能是错误的)。
  • 感谢@FredericBrégier。我将在 github 上为此创建一个问题。

标签: netty


【解决方案1】:

正如评论中提到的@frederic,现在不可能。

在 github 上创建了以下问题 https://github.com/netty/netty/issues/3636

【讨论】:

    猜你喜欢
    • 2011-05-10
    • 2020-10-15
    • 1970-01-01
    • 1970-01-01
    • 2011-11-21
    • 2017-10-23
    相关资源
    最近更新 更多