コード例 #1
0
 /// <summary>
 /// 获取文件流(根据已授权的地址)
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public DownloadStreamResultDto DownloadStream(FileDownloadStreamParam request)
 {
     return(ToolCommon.GetResponse(() =>
     {
         new FileDownloadStreamParamValidator().Validate(request).Check(HttpStatus.Err.Name);
         Uri uri = new Uri(request.Url);
         string host = $"{uri.Scheme}://{uri.Host}";
         return new DownloadStreamResultDto(true, "success",
                                            new HttpClient(host).GetStream(request.Url.Replace(host, "")), null);
     }, message => new DownloadStreamResultDto(message)));
 }
コード例 #2
0
 /// <summary>
 /// 下载文件流
 /// </summary>
 /// <param name="request"></param>
 public DownloadStreamResultDto DownloadStream(FileDownloadStreamParam request)
 {
     try
     {
         new FileDownloadStreamParamValidator().Validate(request).Check(HttpStatus.Err.Name);
         Uri    uri    = new Uri(request.Url);
         string host   = $"{uri.Scheme}://{uri.Host}";
         Stream stream = new HttpClient(host).GetStream(request.Url.Replace(host, ""));
         return(new DownloadStreamResultDto(true, "success", stream, null));
     }
     catch (BusinessException <string> ex)
     {
         return(new DownloadStreamResultDto(ex.Message));
     }
     catch (Exception ex)
     {
         return(new DownloadStreamResultDto(Core.Tools.GetMessage(ex)));
     }
 }
コード例 #3
0
 /// <summary>
 /// 下载文件流
 /// </summary>
 /// <param name="request"></param>
 public DownloadStreamResultDto DownloadStream(FileDownloadStreamParam request)
 {
     throw new NotImplementedException();
 }