bo-oz / vimeo_me2

Vimeo API v3 wrapper for Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Video Upload not working?

heitorado opened this issue · comments

I'm using the upload code provided on the README (Utilizing an upload form in Rails), but from some time until now it has stopped working.

I've put a puts e command inside the rescue VimeoMe2::RequestFailed => e exception rescue block and this is what it shows me upon trying to upload a new video:

image

Everything was working fine a few days ago. No changes were made in the vimeo API, as far as I'm concerned (double-checked the changelog today)

commented

So if everything was working fine there's probably something wrong on Vimeo's site. Try to contact their support desk. Alternatively try Postmen or something to format a request yourself and see what parameter is causing the error... you can easily see the last request by calling your_instance_of_the_class.client.last_request

Hey, thanks for the reply.

So I contacted the support and this is what they told me:

We have been making changes to the API recently that could have an effect on applications that have been not properly updated.
For that library, I recommend modifying it so that all requests, especially those related to upload, provide an accept header with the version set to 3.2.

Following their documentation

I updated on my local version of the gem the headers Hash defined at the start_upload method, as follows:

def start_upload
    headers = {'Content-Type' => 'application/offset+octet-stream',
               'Accept' => 'application/vnd.vimeo.*+json;version=3.2'}
    headers['Tus-Resumable'] = '1.0.0'
    headers['Upload-Offset'] = '0'
    @video.rewind
    video_content = @video.read(@video.size).to_s
    begin
        body = video_content[headers['Upload-Offset'].to_i..-1]
        patch @ticket['upload']['upload_link'], body: body, headers: headers, code:204
        headers['Upload-Offset'] = @client.last_request.headers['upload-offset']
    end while upload_incomplete
end

But the issue continues. I keep receiving the same message. I also tried your suggestion, accessing vimeo_client.client.last_request, but it outputs a blank string to me.

commented

Are you sure the uploads aren't progressing? Did you check Vimeo account? I just tried uploading, and it worked fine, the only thing I noticed is that there are some errors in the last requests. What you could also do is set debug mode on the client:

v = VimeoMe2::User.new('api_key')
v.client.debug = true
v.upload_video(File.open('video.mp4'))

This should give you a more verbose view on what is going on in the background.

commented

Ok, so it seems they changed something to the video json again... what is very annoying is that when you request a video, you get some JSON. Normally, you could change whatever you want (like the name) and POST it back to the same endpoint, that should normally save the changes. The problem is that Vimeo provides attributes in the JSON that you are not allowed to POST as a Free-tier user. Unfortunataly I do not know what attributes that are exactly. I'll try to see if I can remove those from the JSON before the call is made to update the name of the video (which is the last step in the upload process, which is the one that is failing)

commented

Ok, so I found the attribute which is responsible for the error.... very annoying that this is breaking the gem code. I already had a conversation with Vimeo tech support to indicate that they should just ignore attributes which we are not allowed to manipulate, instead of failing the request.

Commit 1023e7c should solve

commented

Did this solve your issue? Otherwise re-open please.