Skip to content

Tus upload taking incredibly long time #157

@typefox09

Description

@typefox09

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions