vimeo.js
vimeo.js copied to clipboard
Is there way to cancel/abort upload request?
Even I am looking for an answer for this!
Hey I actually managed to solve this problem a while ago, so here's my solution.
import axios from 'axios';
import * as tus from 'tus-js-client';
const handleUploadClicked = async () => {
setUploading(true);
const api = 'https://api.vimeo.com/me/videos';
const body = {
name: file.name,
upload: {
approach: 'tus',
size: file.size,
},
};
const headers = {
'Content-Type': 'application/json',
Accept: 'application/vnd.vimeo.*+json;version=3.4',
Authorization: `bearer ${process.env.REACT_APP_VIMEO_ACCESS_TOKEN}`,
};
const response = await axios.post(api, body, { headers });
const uri = response.data.uri;
const endpoint = response.data.upload.upload_link;
const upload = new tus.Upload(file, {
uploadUrl: endpoint,
retryDelays: [0, 1000, 3000, 5000],
onError,
onProgress,
onSuccess: () => onSuccess(uri),
});
upload.start();
upload.pause();
upload.strop();
};
Hope it helps :D
2 days too late. The way I did it was I forked the vimeo.js library and made changes to support pausing and resuming a video. I am planning on cleaning it up and making it open source for everyone who stumbles upon this issue.
any solution for cancelling an upload ?