Exemple #1
0
        private string ConvertFile(DocumentInfo documentInfo)
        {
            string url    = null;
            var    apiUrl = ONLYOFFICE_HOST + CONVERSION_API;
            var    origin = "http://" + HttpContext.Current.Request.ServerVariables.Get("HTTP_HOST").ToString();

            if (documentInfo.FileType == "txt")
            {
                apiUrl += "?async=false&key=" + documentInfo.Key
                          + "&filetype=docx&outputtype=" + documentInfo.FileType
                          + "&url=" + origin + documentInfo.RelativePath;
                Dictionary <string, string> headers = new Dictionary <string, string>();
                headers.Add("Accept", "application/json, text/javascript, */*; q=0.01");
                string result    = WebRequestHelper.GetData(apiUrl, headers);
                var    resultDic = JsonConvert.DeserializeObject <Dictionary <string, object> >(result);
                if (resultDic.ContainsKey("fileUrl"))
                {
                    url = resultDic["fileUrl"].ToString();
                }
            }

            return(url);
        }