private static async Task TestPropatch(WebDavClient webDavClient) { var xns = "http://X_X"; var @params = new ProppatchParameters { PropertiesToSet = new Dictionary <XName, string> { { "{DAV:}getcontenttype", "text/plain" }, { XName.Get("myprop", xns), "myval" } }, PropertiesToRemove = new List <XName> { "{DAV:}ETag" }, Namespaces = new List <NamespaceAttr> { new NamespaceAttr("x", xns) } }; var response = await webDavClient.Proppatch("http://mywebdav:88/1.txt", @params); Console.WriteLine(response.ToString()); Console.WriteLine("PropertyStatuses: {0}", "[\r\n " + string.Join("\r\n ", response.PropertyStatuses.Select(x => x.ToString())) + "\r\n]"); }
public void PutFile(string filename1, byte[] bytes, DateTime lastModified, ProgressCallback progressCallback) { var webDav = GetWebDavClient(); var yaFile = new YandexDiscFile(filename1, Location, webDav); CreateDirectory(Path.GetDirectoryName(yaFile.Location), webDav); using (var stream = new MemoryStream(bytes)) { var props = new PutFileParameters(); props.OperationProgress = args => { progressCallback?.Invoke(args.Progress); }; var response = webDav.PutFile(yaFile.Uri, stream, props); if (!response.IsSuccessful) { throw new ApplicationException($"Unable save file: --> {response.StatusCode} {response.Description}"); } } RetryIfFail(5, () => { var name = XName.Get("x-lastmodified", "DataSync"); var patch = new ProppatchParameters(); patch.PropertiesToSet.Add(name, lastModified.ToString("u")); patch.Namespaces.Add(new NamespaceAttr("u", "DataSync")); var propPatch = webDav.Proppatch(yaFile.Uri, patch); if (!propPatch.IsSuccessful) { throw new ApplicationException($"Unable update file properties: --> {propPatch.StatusCode} {propPatch.Description}"); } return(true); }); }