-
-
Save blackey/c98972150ca00631391dd47debb0a9c2 to your computer and use it in GitHub Desktop.
Download export from VideoXpert
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
public async Task<string> DownloadExport(Uri path, Credentials credentials) | |
{ | |
string exportPath = Path.GetTempFileName(); | |
try | |
{ | |
using (WebClient client = new WebClient()) | |
{ | |
if (credentials.AuthToken.IsValid()) | |
client.Headers.Add(HttpRequestHeader.Cookie, $"auth_token={credentials.AuthToken}"); | |
else | |
{ | |
client.Headers.Add("X-Serenity-User", Utils.I.ToBase64(credentials.Username)); | |
client.Headers.Add("X-Serenity-Password", Utils.I.ToBase64(credentials.Password)); | |
} | |
await client.DownloadFileTaskAsync(path.AbsoluteUri, exportPath); | |
} | |
} | |
catch (Exception e) | |
{ | |
Log.Error(e, "Threw while downloading export"); | |
await DeleteFileOrDir(exportPath); | |
exportPath = null; | |
} | |
return exportPath; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment