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

Tus upload taking incredibly long time #157

Open
typefox09 opened this issue May 20, 2020 · 3 comments
Open

Tus upload taking incredibly long time #157

typefox09 opened this issue May 20, 2020 · 3 comments

Comments

@typefox09
Copy link

typefox09 commented May 20, 2020

Hi, i am experiencing a really long wait time once performing a Tus upload with the api. For a 280mb video (created on my phone) it takes a total of 2 mins and 28 seconds. This is with the chunk size set to 130 * 1024 * 1024 also. I have tried decreasing the chunk size however then it starts taking even longer. What's the best way to have this run in the background so a user can continue browsing?

My code (helper function that takes the uploaded video from form as parameter):

def video_upload(video, offer_pk):

chunk_size = (130 * 1024 * 1024)  # 200 MB

#Initial sending, get an upload link
url = 'https://api.vimeo.com/me/videos'
headers = {
'Authorization': 'bearer %s' % settings.VIMEO_TOKEN, 'Content-Type' : 'application/json', 'Accept' : 'application/vnd.vimeo.*+json;version=3.4'}

data = {'upload' :{ 'approach' : 'tus', 'size' : video.size}, 'name' : str(offer_pk)}

r = requests.post(url, headers=headers, data=json.dumps(data))

if r.status_code == 200:

    uri = r.json()['uri'] # link to final video
    upload_link = r.json()['upload']['upload_link']
    approach = r.json()['upload']['approach']#should be tus

    if approach == 'tus':

        try:
            tus_client = client.TusClient('https://files.tus.vimeo.com')
            uploader = tus_client.uploader(
                    chunk_size=chunk_size,
                    file_stream=video,
                    retries=3,
                    url=upload_link)
            uploader.upload()
        except Exception as e:
            raise exceptions.VideoUploadFailure(
                e,
                'Unexpected error when uploading through tus.'
            )
        
        result = uploader.verify_upload()
        if result == True:
            return uri 
@typefox09 typefox09 reopened this May 20, 2020
@jaylinski
Copy link
Contributor

Version 1.1.0 uses an update tuspy version. Maybe this helps.

@fisherinnovation
Copy link
Contributor

@typefox09 Are you still experiencing this in the latest version?

@typefox09
Copy link
Author

typefox09 commented Jul 28, 2020 via email

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