Skip to content

Instantly share code, notes, and snippets.

@blackey
Created April 10, 2019 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackey/c98972150ca00631391dd47debb0a9c2 to your computer and use it in GitHub Desktop.
Save blackey/c98972150ca00631391dd47debb0a9c2 to your computer and use it in GitHub Desktop.
Download export from VideoXpert
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