index.js
function(fileName, retrying) {
        let file = assets[fileName] || {};
        let key = path.posix.join(uploadPath, fileName);
        let putPolicy = new qiniu.rs.PutPolicy({ scope: bucket + ':' + key });
        let uploadToken = putPolicy.uploadToken(mac);
        let formUploader = new qiniu.form_up.FormUploader(qiniuConfig);
        let putExtra = new qiniu.form_up.PutExtra();

        return new Promise((resolve) => {
          let begin = Date.now();

          formUploader.putFile(
            uploadToken,
            key,
            file.existsAt,
            putExtra,
            function(err, body) {
              // handle upload error
              if (err) {
                // eslint-disable-next-line no-console
                console.log(`Upload file ${fileName} failed: ${err.message || err.name || err.stack}`);
                if (!~retryFiles.indexOf(fileName)) retryFiles.push(fileName);
              } else {
                uploadedFiles++;
              }

              spinner.text = tip(uploadedFiles, retryFiles.length, totalFiles, retrying);
              body.duration = Date.now() - begin;
              resolve(body);
            });
        });
      }
function(fileName, retrying) {
        let file = assets[fileName] || {};
        let key = path.posix.join(uploadPath, fileName);
        let putPolicy = new qiniu.rs.PutPolicy({ scope: bucket + ':' + key });
        let uploadToken = putPolicy.uploadToken(mac);
        let formUploader = new qiniu.form_up.FormUploader(qiniuConfig);
        let putExtra = new qiniu.form_up.PutExtra();

        return new Promise((resolve) => {
          let begin = Date.now();

          formUploader.putFile(
            uploadToken,
            key,
            file.existsAt,
            putExtra,
            function(err, body) {
              // handle upload error
              if (err) {
                // eslint-disable-next-line no-console
                console.log(`Upload file ${fileName} failed: ${err.message || err.name || err.stack}`);
                if (!~retryFiles.indexOf(fileName)) retryFiles.push(fileName);
              } else {
                uploadedFiles++;
              }

              spinner.text = tip(uploadedFiles, retryFiles.length, totalFiles, retrying);
              body.duration = Date.now() - begin;
              resolve(body);
            });
        });
      }
Perform upload to qiniu