/// <summary> /// Download with default timeout of 1 minute /// </summary> /// <param name="shell"></param> /// <param name="destBuff"></param> /// <param name="maxCount"></param> /// <param name="fileName"></param> /// <param name="fromPath"></param> /// <param name="isUserHomeBased"></param> /// <returns></returns> public static Task <int> DownloadAsync(this ISecureShell shell, byte[] destBuff, int maxCount, string fileName, string fromPath, bool isUserHomeBased) { return(shell.DownloadAsync(destBuff, maxCount, fileName, fromPath, isUserHomeBased, TimeSpan.FromMinutes(1))); }
/// <summary> /// Download with timeout /// </summary> /// <param name="shell"></param> /// <param name="fileName"></param> /// <param name="fromPath"></param> /// <param name="isUserHomeBased"></param> /// <param name="timeout"></param> /// <returns></returns> public static Task <string> DownloadAsync(this ISecureShell shell, string fileName, string fromPath, bool isUserHomeBased, TimeSpan timeout) { using (var cts = new CancellationTokenSource(timeout)) { return(shell.DownloadAsync(fileName, fromPath, isUserHomeBased, cts.Token)); } }
/// <summary> /// Download with timeout /// </summary> /// <param name="shell"></param> /// <param name="destBuff"></param> /// <param name="maxCount"></param> /// <param name="fileName"></param> /// <param name="fromPath"></param> /// <param name="isUserHomeBased"></param> /// <param name="timeout"></param> /// <returns></returns> public static Task <int> DownloadAsync(this ISecureShell shell, byte[] destBuff, int maxCount, string fileName, string fromPath, bool isUserHomeBased, TimeSpan timeout) { using (var cts = new CancellationTokenSource(timeout)) { return(shell.DownloadAsync(destBuff, maxCount, fileName, fromPath, isUserHomeBased, cts.Token)); } }
/// <summary> /// Download file /// </summary> /// <param name="shell"></param> /// <param name="options"></param> /// <returns></returns> private static async Task DownloadAsync(ISecureShell shell, CliOptions options) { var file = options.GetValue <string>("-f", "--file"); var from = options.GetValue <string>("-p", "--path"); var str = await shell.DownloadAsync(file, from, options.GetValueOrDefault("-h", "--home", true)); PrintResult(options, str); }
/// <summary> /// Download with default timeout of 1 minute /// </summary> /// <param name="shell"></param> /// <param name="fileName"></param> /// <param name="fromPath"></param> /// <param name="isUserHomeBased"></param> /// <returns></returns> public static Task <string> DownloadAsync(this ISecureShell shell, string fileName, string fromPath, bool isUserHomeBased) { return(shell.DownloadAsync(fileName, fromPath, isUserHomeBased, TimeSpan.FromMinutes(1))); }
/// <summary> /// Download with timeout /// </summary> /// <param name="shell"></param> /// <param name="fileName"></param> /// <param name="fromPath"></param> /// <param name="isUserHomeBased"></param> /// <param name="timeout"></param> /// <returns></returns> public static Task <string> DownloadAsync(this ISecureShell shell, string fileName, string fromPath, bool isUserHomeBased, TimeSpan timeout) => shell.DownloadAsync(fileName, fromPath, isUserHomeBased, new CancellationTokenSource(timeout).Token);