public KalturaFiles GetFilesForMultiRequest(int multiRequestNumber) { KalturaFiles multiRequestParams = new KalturaFiles(); foreach (KeyValuePair <string, FileStream> param in this._Files) { multiRequestParams.Add(multiRequestNumber + ":" + param.Key, param.Value); } return(multiRequestParams); }
public KalturaMetadataProfile AddFromFile(KalturaMetadataProfile metadataProfile, FileStream xsdFile, FileStream viewsFile) { KalturaParams kparams = new KalturaParams(); if (metadataProfile != null) { kparams.Add("metadataProfile", metadataProfile.ToParams()); } KalturaFiles kfiles = new KalturaFiles(); kfiles.Add("xsdFile", xsdFile); kfiles.Add("viewsFile", viewsFile); _Client.QueueServiceCall("metadata_metadataprofile", "addFromFile", kparams, kfiles); if (this._Client.IsMultiRequest) { return(null); } XmlElement result = _Client.DoQueue(); return((KalturaMetadataProfile)KalturaObjectFactory.Create(result)); }
public string Upload(FileStream fileData) { KalturaParams kparams = new KalturaParams(); KalturaFiles kfiles = new KalturaFiles(); kfiles.Add("fileData", fileData); _Client.QueueServiceCall("media", "upload", kparams, kfiles); if (this._Client.IsMultiRequest) { return(null); } XmlElement result = _Client.DoQueue(); return(result.InnerText); }
public KalturaCuePointListResponse AddFromBulk(FileStream fileData) { KalturaParams kparams = new KalturaParams(); KalturaFiles kfiles = new KalturaFiles(); kfiles.Add("fileData", fileData); _Client.QueueServiceCall("cuepoint_cuepoint", "addFromBulk", kparams, kfiles); if (this._Client.IsMultiRequest) { return(null); } XmlElement result = _Client.DoQueue(); return((KalturaCuePointListResponse)KalturaObjectFactory.Create(result)); }
public KalturaMediaEntry UpdateThumbnailJpeg(string entryId, FileStream fileData) { KalturaParams kparams = new KalturaParams(); kparams.AddStringIfNotNull("entryId", entryId); KalturaFiles kfiles = new KalturaFiles(); kfiles.Add("fileData", fileData); _Client.QueueServiceCall("media", "updateThumbnailJpeg", kparams, kfiles); if (this._Client.IsMultiRequest) { return(null); } XmlElement result = _Client.DoQueue(); return((KalturaMediaEntry)KalturaObjectFactory.Create(result)); }
public KalturaGenericDistributionProviderAction AddMrssValidateFromFile(int id, FileStream xsdFile) { KalturaParams kparams = new KalturaParams(); kparams.AddIntIfNotNull("id", id); KalturaFiles kfiles = new KalturaFiles(); kfiles.Add("xsdFile", xsdFile); _Client.QueueServiceCall("contentdistribution_genericdistributionprovideraction", "addMrssValidateFromFile", kparams, kfiles); if (this._Client.IsMultiRequest) { return(null); } XmlElement result = _Client.DoQueue(); return((KalturaGenericDistributionProviderAction)KalturaObjectFactory.Create(result)); }
public KalturaMetadataProfile UpdateViewsFromFile(int id, FileStream viewsFile) { KalturaParams kparams = new KalturaParams(); kparams.AddIntIfNotNull("id", id); KalturaFiles kfiles = new KalturaFiles(); kfiles.Add("viewsFile", viewsFile); _Client.QueueServiceCall("metadata_metadataprofile", "updateViewsFromFile", kparams, kfiles); if (this._Client.IsMultiRequest) { return(null); } XmlElement result = _Client.DoQueue(); return((KalturaMetadataProfile)KalturaObjectFactory.Create(result)); }
public KalturaThumbAsset AddFromImage(string entryId, FileStream fileData) { KalturaParams kparams = new KalturaParams(); kparams.AddStringIfNotNull("entryId", entryId); KalturaFiles kfiles = new KalturaFiles(); kfiles.Add("fileData", fileData); _Client.QueueServiceCall("thumbasset", "addFromImage", kparams, kfiles); if (this._Client.IsMultiRequest) { return(null); } XmlElement result = _Client.DoQueue(); return((KalturaThumbAsset)KalturaObjectFactory.Create(result)); }
public KalturaBulkUpload Add(int conversionProfileId, FileStream csvFileData, KalturaBulkUploadType bulkUploadType, string uploadedBy) { KalturaParams kparams = new KalturaParams(); kparams.AddIntIfNotNull("conversionProfileId", conversionProfileId); KalturaFiles kfiles = new KalturaFiles(); kfiles.Add("csvFileData", csvFileData); kparams.AddStringEnumIfNotNull("bulkUploadType", bulkUploadType); kparams.AddStringIfNotNull("uploadedBy", uploadedBy); _Client.QueueServiceCall("bulkupload", "add", kparams, kfiles); if (this._Client.IsMultiRequest) { return(null); } XmlElement result = _Client.DoQueue(); return((KalturaBulkUpload)KalturaObjectFactory.Create(result)); }
public KalturaMetadata AddFromFile(int metadataProfileId, KalturaMetadataObjectType objectType, string objectId, FileStream xmlFile) { KalturaParams kparams = new KalturaParams(); kparams.AddIntIfNotNull("metadataProfileId", metadataProfileId); kparams.AddStringEnumIfNotNull("objectType", objectType); kparams.AddStringIfNotNull("objectId", objectId); KalturaFiles kfiles = new KalturaFiles(); kfiles.Add("xmlFile", xmlFile); _Client.QueueServiceCall("metadata_metadata", "addFromFile", kparams, kfiles); if (this._Client.IsMultiRequest) { return(null); } XmlElement result = _Client.DoQueue(); return((KalturaMetadata)KalturaObjectFactory.Create(result)); }
public KalturaUploadToken Upload(string uploadTokenId, FileStream fileData, bool resume, bool finalChunk, int resumeAt) { KalturaParams kparams = new KalturaParams(); kparams.AddStringIfNotNull("uploadTokenId", uploadTokenId); KalturaFiles kfiles = new KalturaFiles(); kfiles.Add("fileData", fileData); kparams.AddBoolIfNotNull("resume", resume); kparams.AddBoolIfNotNull("finalChunk", finalChunk); kparams.AddIntIfNotNull("resumeAt", resumeAt); _Client.QueueServiceCall("uploadtoken", "upload", kparams, kfiles); if (this._Client.IsMultiRequest) { return(null); } XmlElement result = _Client.DoQueue(); return((KalturaUploadToken)KalturaObjectFactory.Create(result)); }
public XmlElement DoQueue() { if (_CallsQueue.Count == 0) { _IsMultiRequest = false; return(null); } DateTime startTime = DateTime.Now; this.Log("service url: [" + this._Config.ServiceUrl + "]"); KalturaParams kparams = new KalturaParams(); KalturaFiles kfiles = new KalturaFiles(); // append the basic params kparams.Add("apiVersion", this._ApiVersion); kparams.Add("clientTag", this._Config.ClientTag); kparams.AddIntIfNotNull("format", this._Config.ServiceFormat.GetHashCode()); string url = this._Config.ServiceUrl + "/api_v3/index.php?service="; if (_IsMultiRequest) { url += "multirequest"; int i = 1; foreach (KalturaServiceActionCall call in _CallsQueue) { KalturaParams callParams = call.GetParamsForMultiRequest(i); kparams.Add(callParams); KalturaFiles callFiles = call.GetFilesForMultiRequest(i); kfiles.Add(callFiles); i++; } // map params foreach (KeyValuePair <string, string> item in _MultiRequestParamsMap) { string requestParam = item.Key; string resultParam = item.Value; if (kparams.ContainsKey(requestParam)) { kparams[requestParam] = resultParam; } } } else { KalturaServiceActionCall call = _CallsQueue[0]; url += call.Service + "&action=" + call.Action; kparams.Add(call.Params); kfiles.Add(call.Files); } // cleanup _CallsQueue.Clear(); _IsMultiRequest = false; _MultiRequestParamsMap.Clear(); kparams.Add("sig", this.Signature(kparams)); this.Log("full reqeust url: [" + url + "]"); // build request HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.Timeout = _Config.Timeout; request.Method = "POST"; // Add proxy information if required if (!_Config.ProxyAddress.Equals("") && !_Config.ProxyAddress.Equals(null)) { request.Proxy = new WebProxy(_Config.ProxyAddress); } if (kfiles.Count > 0) { this.PostMultiPartWithFiles(request, kparams, kfiles); } else { this.PostUrlEncodedParams(request, kparams); } // get the response WebResponse response = request.GetResponse(); Encoding enc = System.Text.Encoding.UTF8; StreamReader responseStream = new StreamReader(response.GetResponseStream(), enc); string responseString = responseStream.ReadToEnd(); this.Log("result (serialized): " + responseString); DateTime endTime = DateTime.Now; this.Log("execution time for [" + url + "]: [" + (endTime - startTime).ToString() + "]"); XmlDocument xml = new XmlDocument(); xml.LoadXml(responseString); this.ValidateXmlResult(xml); XmlElement result = xml["xml"]["result"]; this.ThrowExceptionOnAPIError(result); return(result); }
public XmlElement DoQueue() { if (_CallsQueue.Count == 0) { resetRequest(); return(null); } DateTime startTime = DateTime.Now; this.Log("service url: [" + this._Config.ServiceUrl + "]"); KalturaParams kparams = new KalturaParams(); KalturaFiles kfiles = new KalturaFiles(); foreach (string param in clientConfiguration.Keys) { kparams.Add(param, clientConfiguration[param].ToString()); } kparams.AddIfNotNull("format", this._Config.ServiceFormat.GetHashCode()); string url = this._Config.ServiceUrl + "/api_v3"; if (_MultiRequestReturnType != null) { url += "/service/multirequest"; int i = 1; foreach (KalturaServiceActionCall call in _CallsQueue) { KalturaParams callParams = call.GetParamsForMultiRequest(i); kparams.Add(callParams); KalturaFiles callFiles = call.GetFilesForMultiRequest(i); kfiles.Add(callFiles); i++; } // map params foreach (KeyValuePair <string, IKalturaSerializable> item in _MultiRequestParamsMap) { string requestParam = item.Key; IKalturaSerializable resultParam = item.Value; if (kparams.ContainsKey(requestParam)) { kparams[requestParam] = resultParam; } } } else { KalturaServiceActionCall call = _CallsQueue[0]; url += "/service/" + call.Service + "/action/" + call.Action; kparams.Add(call.Params); kfiles.Add(call.Files); } kparams.Add("kalsig", this.Signature(kparams)); string json = kparams.ToJson(); this.Log("full reqeust url: [" + url + "]"); this.Log("full reqeust data: [" + json + "]"); // build request HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); if (kfiles.Count == 0) { request.Timeout = _Config.Timeout; } else { request.Timeout = Timeout.Infinite; } request.Method = "POST"; request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; request.Headers = _Config.RequestHeaders; request.Accept = "application/xml"; // Add proxy information if required createProxy(request, _Config); if (kfiles.Count > 0) { this.PostMultiPartWithFiles(request, json, kfiles); } else { this.PostUrlEncodedParams(request, json); } // get the response using (WebResponse response = request.GetResponse()) { Encoding enc = System.Text.Encoding.UTF8; StreamReader responseStream = new StreamReader(response.GetResponseStream(), enc); string responseString = responseStream.ReadToEnd(); this._ResponseHeaders = response.Headers; string serverName = null; string serverSession = null; for (int i = 0; i < this._ResponseHeaders.Count; ++i) { if (this._ResponseHeaders.Keys[i] == "X-Me") { serverName = this._ResponseHeaders[i]; } if (this._ResponseHeaders.Keys[i] == "X-Kaltura-Session") { serverSession = this._ResponseHeaders[i]; } } if (serverName != null || serverSession != null) { this.Log("server: [" + serverName + "], session: [" + serverSession + "]"); } this.Log("result (serialized): " + responseString); DateTime endTime = DateTime.Now; this.Log("execution time for [" + url + "]: [" + (endTime - startTime).ToString() + "]"); XmlDocument xml = new XmlDocument(); xml.LoadXml(responseString); this.ValidateXmlResult(xml); XmlElement result = xml["xml"]["result"]; this.ThrowExceptionOnAPIError(result); if (!IsMultiRequest) { resetRequest(); } return(result); } }