nodejs SDK formUploader.putFile()方法报错

新手上路,请多包涵
//getFiles.getFilesUrl 是个promise
 getFiles.getFilesUrl(path)
        .then((files,rejectValue)=>{
            if(rejectValue){
                console.log('there is some err on getFilesUrl Funciton and the rejectValue is :' + rejectValue);
                throw Error();
            } 
            //筛选出文件,防止上传文件夹而导致的错误
            let filesPaths = files.filter(file => {
            let filePath = path + file;
            if(path!='./' || path != '/'){
                filePath =  path +'/'+ file;
            }
           
            let stat = fs.lstatSync(filePath);
            if(stat.isFile()) { 
                    return filePath;
            }else{
                    console.log("Warn!!!it isn't a file that can't to be uploaded :  " + file)
                }
            });
       
          filesPaths.map(file => {
                var key = prefix + file;
                //var localFile = file;
                var localFile;
                if(path!='./' || path != '/'){
                    localFile =  path +'/'+ file;
                }
                formUploader.putFile(uploadToken, key, localFile, putExtra, function(respErr,
                    respBody, respInfo) {
                    if (respErr) {
                        throw respErr;
                    }
                if (respInfo.statusCode == 200) {
                    console.log(respBody);
                } else {
                    console.log("there may be some err with code :" + respInfo.statusCode +'and Info : ' + respBody)           
                }
                });
            });

        })
        .catch(err => {
            
            console.log('meet err:'+err);
        });
   

错误:TypeError: Cannot read property 'forEach' of undefined
在:

.catch(err => {    
        console.log('meet err:'+err);
   });

发出错误

阅读 3.6k
2 个回答
✓ 已被采纳新手上路,请多包涵

错误原因:zone 是 qiniu对象,而不是字符串

这个看上去和putFile没有关系,是你业务逻辑抛出的错误。

logo
七牛云问答
子站问答
访问
宣传栏