@@ -5,7 +5,6 @@ const SparkMD5 = require('spark-md5');
55const chalk = require ( 'chalk' ) ;
66const prompts = require ( 'prompts' ) ;
77const path = require ( 'path' ) ;
8- const FormData = require ( 'form-data' ) ;
98require ( 'winston-daily-rotate-file' ) ;
109const logger = require ( '../lib/log' ) ;
1110const ProgressBar = require ( 'progress' ) ;
@@ -29,26 +28,24 @@ process.on('uncaughtException', error => {
2928const upload = async ( filePath , parts = [ ] ) => {
3029 const totalChunk = Math . ceil ( fileSize / CHUNK_SIZE ) ;
3130
32- const bar = new ProgressBar ( ':bar [:current/:total] :percent' , { total : totalChunk } ) ;
31+ const bar = new ProgressBar ( ':bar [:current/:total] :percent ' , { total : totalChunk } ) ;
3332 const uploadChunk = async ( currentChunk , currentChunkIndex , parts , isRetry ) => {
3433 if ( parts . some ( ( { partNumber, size } ) => partNumber === currentChunkIndex && size === currentChunk . length ) ) {
3534 bar . tick ( ) ;
3635 return Promise . resolve ( ) ;
3736 }
3837
39- const form = new FormData ( ) ;
40- form . append ( 'chunk' , currentChunk , {
41- filename : requestUrl . replace ( / ^ h t t p ( s ) ? : \/ \/ .+ ?\/ .+ ?\/ .+ ?\/ / , '' )
42- } ) ;
4338 try {
4439 await _uploadChunk ( requestUrl , {
4540 uploadId,
4641 version,
4742 partNumber : currentChunkIndex ,
4843 size : currentChunk . length ,
49- form
44+ currentChunk
5045 } , {
51- headers : form . getHeaders ( ) ,
46+ headers : {
47+ 'Content-Type' : 'application/octet-stream'
48+ } ,
5249 Authorization
5350 } ) ;
5451 bar . tick ( ) ;
@@ -163,7 +160,7 @@ const getFileMD5 = async (filePath) => {
163160 console . log ( `\n开始计算 MD5\n` )
164161 logger . info ( '开始计算 MD5' )
165162
166- const bar = new ProgressBar ( ':bar [:current/:total] :percent' , { total : totalChunk } ) ;
163+ const bar = new ProgressBar ( ':bar [:current/:total] :percent ' , { total : totalChunk } ) ;
167164 await new Promise ( resolve => {
168165 stream = fs . createReadStream ( filePath , { highWaterMark : CHUNK_SIZE } )
169166 stream . on ( 'data' , chunk => {
0 commit comments