I've been trying to sort this out for weeks without any luck. I'm pretty sure i lack basic knowledge in memory management in .NET. I'm not sure where to start googling though.
This is the API i've been following: https://developer.vimeo.com/api/upload#start-streaming
If a user uploads a video which is under 100mb it works okey, but it takes forever to upload. However, if the file is more than 100mb, the connection times out because the server lacks memory. I think i need to upload the file in smaller parts.
This is my current uploadmethod:
public static string UploadVideo(HttpPostedFileBase file, dynamic ticket)
{
try
{
var apiUrl = ticket.upload_link_secure;
byte[] fileData;
using (var binaryReader = new BinaryReader(file.InputStream))
{
fileData = binaryReader.ReadBytes(file.ContentLength);
}
using (var client = new WebClient())
{
client.Headers.Add(HttpRequestHeader.Authorization, "bearer " + AccessToken);
client.Headers.Add("Accept", "application/vnd.vimeo.*+json;version=3.0");
client.UploadData(apiUrl, "PUT", fileData.ToArray());
}
}
catch (Exception ex)
{
EventLog.LogEvent("Error uploading video: ", ex.Message, ex.ToString(),
EventTypes.Error, false, "");
}
return "Failed";
}
Right now i'm uploading the whole thing into one byte array which probably is bad practise. Do i take the whole content and divide it into parts by, lets say 3mb and then upload it? Wouldnt that force me to call verifyUpload alot of times just to upload one video? Lets say the