private GetRequest ( string uri ) : |
||
uri | string | |
return |
/// <summary> /// <paramref name="ftpClient"/>를 이용하여 비동기 방식으로 웹 응답을 받습니다. /// </summary> /// <param name="ftpClient"></param> /// <param name="uri"></param> /// <param name="method"></param> /// <returns></returns> /// <example> /// <code> /// // 특정 파일을 FTP 서버에서 다운로드 받습니다. /// var responseTask = ftpClient.GetResponseTask(uri, WebRequestMethods.Ftp.DownloadFile); /// var stream = ((FtpWebResponse)responseTask.Result).GetResponseStream(); /// </code> /// </example> /// <seealso cref="GetResponseStreamTask"/> public static Task <WebResponse> GetResponseTask(this FtpClient ftpClient, string uri, string method) { var request = ftpClient.GetRequest(uri); request.Method = method; return(GetResponseTask(ftpClient, request)); }
/// <summary> /// 비동기 방식으로 요청 스트림을 구합니다. /// </summary> /// <param name="ftpClient"></param> /// <param name="uri"></param> /// <param name="method"></param> /// <returns></returns> public static Task <Stream> GetRequestStreamTask(this FtpClient ftpClient, string uri, string method) { if (IsDebugEnabled) { log.Debug("Ftp ResponseStream을 비동기 방식으로 호출합니다. uri=[{0}], method=[{1}]", uri, method); } var request = ftpClient.GetRequest(uri); request.Method = method; return(Task <Stream> .Factory.FromAsync(request.BeginGetRequestStream, request.EndGetRequestStream, null)); }
/// <summary> /// FTP 서버의 원격 파일명을 변경합니다. /// </summary> /// <param name="ftpClient"></param> /// <param name="srcFilename"></param> /// <param name="destFilename"></param> /// <returns></returns> public static Task <bool> RenameFileTask(this FtpClient ftpClient, string srcFilename, string destFilename) { srcFilename.ShouldNotBeWhiteSpace("srcFilename"); destFilename.ShouldNotBeWhiteSpace("destFilename"); if (IsDebugEnabled) { log.Debug("원격 파일명을 변경합니다... srcFilename=[{0}], destFilename=[{1}]", srcFilename, destFilename); } var src = ftpClient.GetFullPath(srcFilename); var dest = ftpClient.GetFullPath(destFilename); if (src == dest) { return(Task.Factory.FromResult(true)); } var request = ftpClient.GetRequest(src); request.Method = WebRequestMethods.Ftp.Rename; request.RenameTo = destFilename; return (ftpClient .GetResponseTask(request) .ContinueWith(task => { var result = task.IsCompleted; task.Result.Close(); if (IsDebugEnabled) { log.Debug("원격 파일명을 비동기 방식으로 변경했습니다!!! srcFilename=[{0}], destFilename=[{1}]", srcFilename, destFilename); } return result; }, TaskContinuationOptions.ExecuteSynchronously)); }