Created
August 14, 2020 09:19
-
-
Save pksorensen/01fd8314d0994c16af8e7804e338cec5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var clientParams = new WebDavClientParams | |
{ | |
BaseAddress = new Uri("https://xxxxx.agillic.eu/"), | |
Credentials = new NetworkCredential("", "") | |
}; | |
var _client = new WebDavClient(clientParams); | |
var result = await _client.Propfind("https://xxxx.agillic.eu/api/export/files/ActivitiesExport/"); | |
foreach(var f in result.Resources) | |
{ | |
var r = f.Properties.First(k => k.Name.LocalName == "resourcetype").Value; | |
var isFolder = r.Contains("collection"); | |
if (!f.IsCollection) | |
{ | |
if ( f.DisplayName.EndsWith(".zip",StringComparison.OrdinalIgnoreCase)) | |
{ | |
using (var file = await _client.GetFileResponse(new Uri(clientParams.BaseAddress+Uri.UnescapeDataString( f.Uri)), false, new GetFileParameters { })) | |
{ | |
var stream = await file.Content.ReadAsStreamAsync(); | |
using (var target = File.OpenWrite(Path.GetFileName(Uri.UnescapeDataString(f.Uri)))) | |
{ | |
await stream.CopyToAsync(target); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment