Example #1
0
        /// <summary>
        /// 3.3.5.1.1 CheckFileInfo
        /// [MS-WOPI] 3.3.5.1.1.2 Response Body
        /// </summary>
        public void CheckFileInfo()
        {
            string url = String.Format("{0}", Source);

            using (OpenWOPIWebClient client = new OpenWOPIWebClient(url, AccessToken.access_token, AccessToken.access_token_ttl, ProofKey))
            {
                string data = client.DownloadString(url);
                JavaScriptSerializer jss = new JavaScriptSerializer();
                var d = jss.Deserialize <Dictionary <string, string> >(data);
                BreadcrumbFolderUrl  = d["BreadcrumbFolderUrl"];
                BreadcrumbFolderName = d["BreadcrumbFolderName"];
                BaseFileName         = d["BaseFileName"];
                CloseUrl             = d["CloseUrl"];
                HostEditUrl          = d["HostEditUrl"];
                WebEditingDisabled   = bool.Parse(d["WebEditingDisabled"]);
                SupportsUpdate       = bool.Parse(d["SupportsUpdate"]);
                SupportsLocks        = bool.Parse(d["SupportsLocks"]);
                DownloadUrl          = d["DownloadUrl"];
                Version          = d["Version"];
                OwnerId          = d["OwnerId"];
                SHA256           = d["SHA256"];
                UserFriendlyName = d["UserFriendlyName"];
                Size             = int.Parse(d["Size"]);
            }
        }
Example #2
0
        /// <summary>
        /// 3.3.5.3.1 GetFile
        /// </summary>
        public void GetFile()
        {
            string url = String.Format("{0}/contents", Source);

            using (OpenWOPIWebClient client = new OpenWOPIWebClient(url, AccessToken.access_token, AccessToken.access_token_ttl, ProofKey))
            {
                client.Headers.Add("X-WOPI-MaxExpectedSize", MaxDocumentSize.ToString());
                Data = client.DownloadData(url);
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        public void PutFile()
        {
            string url = String.Format("{0}/contents", Source);

            using (OpenWOPIWebClient client = new OpenWOPIWebClient(url, AccessToken.access_token, AccessToken.access_token_ttl, ProofKey))
            {
                client.Headers.Add("X-WOPI-Override", "PUT");
                client.Headers.Add("X-WOPI-Size", Data.Length.ToString());
                //client.Headers.Add("X-WOPI-Lock", "Lock-ID");
                client.UploadData(url, Data);
            }
        }
Example #4
0
        /// <summary>
        /// X-WOPI-Lock
        /// </summary>
        public string LockFile()
        {
            string url = String.Format("{0}", Source);

            using (OpenWOPIWebClient client = new OpenWOPIWebClient(url, AccessToken.access_token, AccessToken.access_token_ttl, ProofKey))
            {
                Lock = Guid.NewGuid().ToString();
                client.Headers.Add("X-WOPI-Override", "LOCK");
                client.Headers.Add("X-WOPI-Lock", Lock);
                client.UploadString(url, string.Empty);
                return(Lock);
            }
        }