File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ export const multipart = (app: Application) => {
151151 }
152152 // otherwise, it's a stream
153153 // part.fieldname, part.filename, part.encoding, part.mime
154+ // _readableState.length
154155 // part.readableLength 31492 检查单个文件的大小
155156 // 超过长度,报错
156157 // 检查extension,报错
@@ -161,7 +162,7 @@ export const multipart = (app: Application) => {
161162 throw new FileExtensionException ( { msg : `不支持类型为${ ext } 的文件` } ) ;
162163 }
163164 const { valid, conf } = checkSingleFileSize (
164- part . readableLength ,
165+ part . _readableState . length ,
165166 opts && opts . singleLimit
166167 ) ;
167168 if ( ! valid ) {
@@ -170,7 +171,7 @@ export const multipart = (app: Application) => {
170171 } ) ;
171172 }
172173 // 计算总大小
173- totalSize += part . readableLength ;
174+ totalSize += part . _readableState . length ;
174175 const tmp = cloneDeep ( part ) ;
175176 files . push ( tmp ) ;
176177 // 恢复再次接受data
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ export class Uploader {
8080 * 生成图片的md5
8181 */
8282 public generateMd5 ( data : any ) {
83- const buf = data . readableBuffer . _getBuffer ( data . readableLength ) ;
83+ const buf = data . _readableState . buffer . head . data ;
8484 const md5 = crypto . createHash ( 'md5' ) ;
8585 return md5 . update ( buf ) . digest ( 'hex' ) ;
8686 }
You can’t perform that action at this time.
0 commit comments