阿里云oss 上传视频报错404?
使用阿里云分片和断点上传一直报错
翻译过来说是id
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);
});
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论