public void Words_DocumentProtection_Tests() { try { storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/doc-sample.doc", Utils.CloudStorage_Output_Folder + "/doc-sample.doc"); WordsProtectionDataResponse wordsProtectionDataResponse = wordsService.WordsDocumentProtection.ReadDocumentProtectionCommonInfo("doc-sample.doc", Utils.CloudStorage_Output_Folder); WordsProtectionRequest wordsProtectionRequest = new WordsProtectionRequest("aspose", "aspose", ProtectionType.ReadOnly); wordsService.WordsDocumentProtection.ProtectDocument("doc-sample.doc", string.Empty, wordsProtectionRequest, Utils.CloudStorage_Output_Folder); WordsProtectionRequest wordsProtectionRequest2 = new WordsProtectionRequest("aspose", "aspose2", ProtectionType.ReadOnly); wordsService.WordsDocumentProtection.ChangeDocumentProtection("doc-sample.doc", string.Empty, wordsProtectionRequest2, Utils.CloudStorage_Output_Folder); WordsProtectionRequest wordsProtectionRequest3 = new WordsProtectionRequest("aspose2", string.Empty, ProtectionType.NoProtection); wordsService.WordsDocumentProtection.UnprotectDocument("doc-sample.doc", string.Empty, wordsProtectionRequest3, Utils.CloudStorage_Output_Folder); //storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/doc-sample.doc", Utils.Local_Output_Path + "/doc-sample.doc"); } catch (Exception ex) { Assert.Fail(ex.Message); } }
/// <summary> /// Change document protection. /// </summary> /// <param name="name">The file name.</param> /// <param name="filename">Result name of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document</param> /// <param name="folder">The document folder.</param> /// <param name="storage">The document storage.</param> public void ChangeDocumentProtection(string name, string filename, WordsProtectionRequest protectionRequest, string folder, string storage = "") { // POST words/{name}/protection?appSid={appSid}&filename={filename}&storage={storage}&folder={folder} string apiUrl = string.Format(@"words/{0}/protection?filename={1}&storage={2}&folder={3}", name, filename, storage, folder); ServiceController.Post(apiUrl, AppSid, AppKey, JsonConvert.SerializeObject(protectionRequest)); }