我有一个非常简单的设置 - 用户从图库中选择一个视频,我们将视频转换为一个 blob,然后我们创建 Vimeo 上传 url(我已经确认它是一致的),然后我们创建一个 Upload() 对象来上传通过 tus 到 Vimeo 的视频:
const blob = await fetch(`data:video/mp4;base64,${b64}`).then((res) =>
res.blob()
);
const uploadLink = await this.generateVideoUploadUrl(blob.size);
let fileName = this.path.substring(this.path.lastIndexOf('/') + 1);
const upload = new Upload(blob, {
endpoint: uploadLink,
uploadUrl: uploadLink,
retryDelays: [0, 1000, 3000, 5000],
onError: function (error) {
console.log('Failed because: ' + error);
},
onProgress: function (bytesUploaded, bytesTotal) {
console.log('progress');
var percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2);
console.log(bytesUploaded, bytesTotal, percentage + '%');
},
onSuccess: function () {
console.log('Download %s from %s', upload.file, upload.url);
},
});
upload.start();
但是,就正在上传的视频或控制台中的任何迹象而言,我一无所获。为什么会这样?
运行时环境:Ionic 5 with Capacitor
使用的 tus-js-client 版本:tus-js-client@2.1.0
使用的tus服务器软件:使用Vimeo