| | |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(uploadImageObj); |
| | | var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_UploadImage, requestJson); |
| | | if(revertObj.Code == StateCode.SUCCESS) |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | | { |
| | | if(revertObj.Data != null) |
| | | if (revertObj.Data != null) |
| | | { |
| | | return revertObj.Data.ToString(); |
| | | } |
| | |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(imageKey)) return null; |
| | | |
| | | |
| | | byte[] imageBytes; |
| | | if (!ignoreCache && Exists(imageKey)) |
| | | { |
| | |
| | | { |
| | | //云端下载 |
| | | imageBytes = GetImageDownloadUrlWithRegionUrl(imageKey, regionUrl); |
| | | if(imageBytes != null) |
| | | if (imageBytes != null) |
| | | { |
| | | //保存到本地 |
| | | WriteFileByBytes(imageKey, imageBytes); |
| | | } |
| | | |
| | | |
| | | } |
| | | return imageBytes; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 下载用户头像 |
| | | /// </summary> |
| | | /// <param name="imageUrl"></param> |
| | | /// <param name="ignoreCache">忽略缓存</param> |
| | | /// <param name="regionUrl">指定服务器域名,传空为使用当前用户地址</param> |
| | | /// <returns></returns> |
| | | public byte[] DownImageByImageUrl(string imageUrl, bool ignoreCache = false) |
| | | { |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(imageUrl)) return null; |
| | | |
| | | byte[] imageBytes; |
| | | if (!ignoreCache && Exists(imageUrl)) |
| | | { |
| | | //本地有缓存 |
| | | imageBytes = ReadFile(imageUrl); |
| | | } |
| | | else |
| | | { |
| | | //下载 |
| | | imageBytes = HttpUtil.HttpsDownload(imageUrl); |
| | | if (imageBytes != null) |
| | | { |
| | | //保存到本地 |
| | | WriteFileByBytes(imageUrl, imageBytes); |
| | | } |
| | | |
| | | } |
| | | return imageBytes; |
| | | } |
| | | catch |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | } |
| | | } |