Search code examples
c#vimeovimeo-api

Resumable uploads with WebClient class


I'm trying to upload a video but getting an empty result from the server (0 bytes).

For step 1, i'm calling the api like that:

var json = vc.UploadCreate("/me/videos", "tus", 3021075, "POST");

"tus" is the approach, "3021075" is the file size. I'm saving the upload_link & uri, and then making the second request like that:

string filepath = @"C:\videoplayback.mp4";
var rslt = vc.UploadPatch2(uploadlink, filepath);

My UploadPatch2() method:

WebClient wc = new WebClient();
wc.Headers.Add("Tus-Resumable", "1.0.0");
wc.Headers.Add("Upload-Offset", "0");
wc.Headers.Add("Content-Type", "application/offset+octet-stream");
wc.Headers.Add("Authorization", "Bearer ******");

var file = File.ReadAllBytes(filepath);

var result = wc.UploadData(upload_link, "PATCH", file);

When trying to send "PATCH" request as it says in the API, it fails with the error:

The remote server returned an error: (404) Not Found.

When doing it with "PUT", there is no exception but "result" gets 0 bytes back from the server.


Solution

  • Well it seems this is just a bug with Vimeo's API. The file gets uploaded, but the response is error 404.