| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 | 
							- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using System.IO;
 
- using System.Net;
 
- using System.Net.Http;
 
- using System.Threading.Tasks;
 
- using ET;
 
- using FairyGUI;
 
- using UnityEngine;
 
- using UnityEngine.Networking;
 
- namespace GFGGame
 
- {
 
-     public static class PictureStorageHelper
 
-     {
 
-         //将图片上传到华为云
 
-         public static async Task<bool> PushToHWCloud(string signUrl, byte[] buffer)
 
-         {
 
-             HttpContent content = new ByteArrayContent(buffer);
 
-             HttpClient httpClient = new HttpClient(new HttpClientHandler() { UseCookies = false });
 
-             HttpResponseMessage response = await httpClient.PutAsync(signUrl, content);
 
-             response.EnsureSuccessStatusCode();
 
-             await response.Content.ReadAsStreamAsync();
 
-             if (response.StatusCode != HttpStatusCode.OK)
 
-             {
 
-                 ViewManager.Hide<ModalStatusView>();
 
-                 PromptController.Instance.ShowFloatTextPrompt("上传资源失败");
 
-                 return false;
 
-             }
 
-             else
 
-             {
 
-                 return true;
 
-             }
 
-         }
 
-         public static IEnumerator Download(List<long> list, int startIndex, Action callBack = null)
 
-         {
 
-             for (int i = startIndex; i < list.Count; i++)
 
-             {
 
-                 PoemGalleryData data = PoemGalleryDataManager.Instance.GetGalleryDataById(list[i]);
 
-                 if (data.Ntexture != null) continue;
 
-                 int count = 0;
 
-                 yield return DownloadPicture(data, count);
 
-             }
 
-             if (callBack != null) callBack();
 
-             ET.Log.Debug("Download  finish!!!");
 
-         }
 
-         private static IEnumerator DownloadPicture(PoemGalleryData data, int count)
 
-         {
 
-             if (count >= 5)
 
-             {
 
-                 ET.Log.Error("Download  fild!!!");
 
-                 data.Ntexture = null;
 
-                 ViewManager.Hide<ModalStatusView>();
 
-                 yield return null;
 
-             }
 
-             using (UnityWebRequest request = UnityWebRequestTexture.GetTexture(data.PictureTempUrl))
 
-             {
 
-                 yield return request.SendWebRequest();
 
-                 if (request.result == UnityWebRequest.Result.ProtocolError || request.result == UnityWebRequest.Result.ConnectionError)
 
-                 {
 
-                     PromptController.Instance.ShowFloatTextPrompt("下载失败");
 
-                     ET.Log.Error("Download  fild!!!");
 
-                     count += 1;
 
-                     yield return DownloadPicture(data, count);
 
-                 }
 
-                 else
 
-                 {
 
-                     Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
 
-                     data.Ntexture = new NTexture(texture);
 
-                     EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH_ONE);
 
-                 }
 
-             }
 
-         }
 
-         public static IEnumerator Download(List<PoemPhotoData> list)
 
-         {
 
-             for (int i = 0; i < list.Count; i++)
 
-             {
 
-                 PoemPhotoData data = list[i];
 
-                 if (data == null || data.Ntexture != null) continue;
 
-                 int count = 0;
 
-                 yield return DownloadPicture(data, count);
 
-             }
 
-             ET.Log.Debug("Download  finish!!!");
 
-             EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH);
 
-         }
 
-         private static IEnumerator DownloadPicture(PoemPhotoData data, int count)
 
-         {
 
-             if (count >= 5)
 
-             {
 
-                 ET.Log.Error("Download  fild!!!");
 
-                 data.Ntexture = null;
 
-                 ViewManager.Hide<ModalStatusView>();
 
-                 yield return null;
 
-             }
 
-             using (UnityWebRequest request = UnityWebRequestTexture.GetTexture(data.PictureTempUrl))
 
-             {
 
-                 yield return request.SendWebRequest();
 
-                 if (request.result == UnityWebRequest.Result.ProtocolError || request.result == UnityWebRequest.Result.ConnectionError)
 
-                 {
 
-                     PromptController.Instance.ShowFloatTextPrompt("下载失败");
 
-                     count += 1;
 
-                     yield return DownloadPicture(data, count);
 
-                 }
 
-                 else
 
-                 {
 
-                     Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
 
-                     data.Ntexture = new NTexture(texture);
 
-                     data.Bytes = texture.EncodeToJPG();
 
-                 }
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |