I'm having some problems with the YouTube API using the ResumeAsync() method.
Here is my code...
YouTubeService youtube = await AuthService.AuthenticateYouTubeAsync(auth);
ResumableUpload<Video, Video> vidUploadReq = null;
var video = new Video();
video.Snippet = new VideoSnippet();
video.Snippet.Title = videoToUpload.Title;
video.Snippet.Description = videoToUpload.Description;
video.Snippet.Tags = videoToUpload.Tags;
video.Snippet.CategoryId = videoToUpload.CategoryID;
video.Status = new VideoStatus();
video.Status.PrivacyStatus = videoToUpload.PrivacyStatus;
var filePath = videoToUpload.LocalFilePath;
// Get chunk size and make sure it's valid
int chunkSizeBytes = defaultChunkSizeKB * 1024;
using (var fileStream = new FileStream(filePath, FileMode.Open))
{
vidUploadReq = youtube.Videos.Insert(video, "snippet,status", fileStream, "video/*");
vidUploadReq.ProgressChanged += videoUploadRequest_ProgressChanged;
vidUploadReq.ResponseReceived += videoUploadRequest_ResponseReceived;
vidUploadReq.ChunkSize = chunkSizeBytes;
await vidUploadReq.UploadAsync(token);
}
Where does resuming fit into this?
Am I expected to serialize the ResumableUpload object for when I restart the application?
It seems like I need to preserve UploadUri for next time, and next time, set this UploadUri and StreamLength properties. However, both of these fields are PRIVATE in the API.
Is there a better way other than using reflection to set these private properties?