public static HttpWebRequest CreateForNewUpload(Uri uri, IYoutubeVideo video, IYoutubeAccount account) { LOGGER.Info($"Creating web request for video: '{video.Path}' and account with id: {account.Id} and title: '{account.Title}'"); var request = CreateWithAuthHeader(uri.AbsoluteUri, "PUT", account.GetActiveToken()); request.ContentLength = video.File.Length; request.ContentType = MimeMapping.GetMimeMapping(video.File.Name); // Am Leben halten (wichtig bei großen Dateien)! request.ServicePoint.SetTcpKeepAlive(true, 10000, 1000); request.AllowWriteStreamBuffering = false; request.Timeout = int.MaxValue; return(request); }
public static HttpWebRequest CreateForResumeUpload(Uri uri, IYoutubeVideo video, IYoutubeAccount account, long lastbyte) { LOGGER.Info($"Creating web request for resumable upload of video: '{video.Path}' and account with id: {account.Id} and title: '{account.Title}' from last byte: {lastbyte}"); var request = CreateWithAuthHeader(uri.AbsoluteUri, "PUT", account.GetActiveToken()); request.Headers.Add($"Content-Range: bytes {lastbyte + 1}-{video.File.Length - 1}/{video.File.Length}"); request.ContentLength = video.File.Length - (lastbyte + 1); LOGGER.Info($"Content-Range header: 'bytes {lastbyte + 1}-{video.File.Length - 1}/{video.File.Length}'"); LOGGER.Info($"Content-Length header: {video.File.Length - (lastbyte + 1)}"); // Am Leben halten (wichtig bei großen Dateien)! request.ServicePoint.SetTcpKeepAlive(true, 10000, 1000); request.AllowWriteStreamBuffering = false; request.Timeout = int.MaxValue; return(request); }