阿里云oss 上传视频报错404?

使用阿里云分片和断点上传一直报错
image.png
image.png
翻译过来说是id
image.png

function upload (event) {
  return new Promise((resolve, reject) => {
    client = new OSS({
      region: OSSConfig.ossParams.region,
      accessKeyId: OSSConfig.ossParams.accessKeyId,
      accessKeySecret: OSSConfig.ossParams.accessKeySecret,
      bucket: OSSConfig.ossParams.bucket,
      timeout: 120000 
    })
    let file = event
    let randomName = `${OSSConfig.ossParams.path}${file.uid}`
    co(function* () {
    //   let result = yield client.multipartUpload(randomName, file)
    let result = yield client.multipartUpload(randomName, file, {
        parallel,
        partSize,
        progress: onMultipartUploadProgress
      })
      console.log(result, 'result.name');
      resolve(`${OSSConfig.uploadHost}/${result.name}`)
    }).catch(function (err) {
      reject(err)
    })
  })
}
async function onMultipartUploadProgress(progress, checkpoint) {
    console.log(progress, checkpoint);
    // console.log(`${checkpoint.file.name} 上传进度 ${progress}`);
    // 上传进度
    // window.$progress = progress;
    checkpoints[checkpoint.uploadId] = checkpoint;
    // const { Expiration } = credentials;
    // console.log(credentials);
    await resumeMultipartUpload();
  }

  // 断点续传
async function resumeMultipartUpload() {
    Object.values(checkpoints).forEach((checkpoint) => {
      const { uploadId, file, name } = checkpoint;
      console.log(file, 'uploadId')
      client.multipartUpload(uploadId, file, {
        parallel,
        partSize,
        progress: onMultipartUploadProgress,
        checkpoint
      }).then(result => {
        // console.log('before delete checkpoints === ', result);
        client.cancel();
        delete checkpoints[checkpoint.uploadId];
        console.log('after delete checkpoints === ', name);
        // const url = `http://${bucket}.${region}.aliyuncs.com/${name}`;
        // console.log(`Resume multipart upload ${file.name} succeeded, url === `, url)
      }).catch(err => {
        // client.cancel();
        // window.$cancelBoolean = true;
        console.log(err);
      });
    });
  }
阅读 712
评论
    0 个回答
    撰写回答

    登录后参与交流、获取后续更新提醒

    相似问题
    推荐文章