// >> END recordings-downloader-step-6 // >> START recordings-downloader-step-8 // Download Recordings private static void downloadRecording(BatchDownloadJobResult recording) { Console.WriteLine("Downloading now. Please wait..."); String conversationId = recording.ConversationId; String recordingId = recording.RecordingId; String sourceURL = recording.ResultUrl; String errorMsg = recording.ErrorMsg; String targetDirectory = "."; // If there is an errorMsg skip the recording download if (errorMsg != null) { Console.WriteLine("Skipping this recording. Reason: " + errorMsg); return; } // Download the recording if available String ext = getExtension(recording); string filename = conversationId + "_" + recordingId; using (WebClient wc = new WebClient()) wc.DownloadFile(sourceURL, targetDirectory + "\\" + filename + "." + ext); }
// >> END recordings-downloader-step-8 // >> START recordings-downloader-step-7 // Get extension of a recording private static string getExtension(BatchDownloadJobResult recording) { // Store the contentType to a variable that will be used later to determine the extension of recordings. string contentType = recording.ContentType; // Split the text and gets the extension that will be used for the recording string ext = contentType.Split('/').Last(); // For the JSON special case if (ext.Length >= 4) { ext = ext.Substring(0, 4); } return(ext); }