egg icon indicating copy to clipboard operation
egg copied to clipboard

文件大小获取有误

Open zhenmang opened this issue 6 years ago • 4 comments

What happens?

前端上传文件,后端接收时,获取不到正确的文件大小值。

Mini Showcase Repository(REQUIRED)

const stream = await ctx.getFileStream(); console.log(stream.length); 当文件很小,length值是准确的,当文件稍微大点,length值不正确,显示的会是一个固定的数字64556。 例如上传下图http://t8.baidu.com/it/u=1484500186,1503043093&fm=79&app=86&f=JPEG?w=1280&h=853

Context

  • Node Version: v12.15.0
  • Egg Version:@2.26.0
  • Plugin Name:egg-multipart
  • Plugin Version:2.10.1
  • Platform:macOS Mojave

zhenmang avatar Apr 02 '20 12:04 zhenmang

这是 Node 自带的 stream 类,可以去看下 Node 官方文档。

https://github.com/eggjs/egg-multipart/blob/master/app/extend/context.js#L217

atian25 avatar Apr 02 '20 12:04 atian25

我也遇到过,可能是nginx转发大小的限制,后面我也没有找出来,直接改用file文件模式了。 相同问题:https://github.com/eggjs/egg/issues/4201

oneWalker avatar Apr 03 '20 01:04 oneWalker

请问,具体是怎么解决的,可以给下 file模式的代码么,我想学习一下

pxim avatar Sep 01 '22 01:09 pxim

您好,您的邮件我已收到

zhenmang avatar Sep 01 '22 01:09 zhenmang