Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there way to cancel/abort upload request? #126

Open
pavanjadhaw opened this issue Apr 12, 2020 · 5 comments
Open

Is there way to cancel/abort upload request? #126

pavanjadhaw opened this issue Apr 12, 2020 · 5 comments

Comments

@pavanjadhaw
Copy link

No description provided.

@elitelinuxuser
Copy link

Even I am looking for an answer for this!

@pavanjadhaw
Copy link
Author

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();
};

@pavanjadhaw
Copy link
Author

Hope it helps :D

@elitelinuxuser
Copy link

elitelinuxuser commented May 28, 2020

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.

@ikramooe
Copy link

any solution for cancelling an upload ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants