|
@@ -1,3 +1,4 @@
|
|
|
+using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.IO;
|
|
@@ -70,41 +71,23 @@ namespace GFGGame
|
|
|
}
|
|
|
|
|
|
//将图片上传到华为云
|
|
|
- public static string PushToHWCloud(string signUrl, byte[] buffer)
|
|
|
+ public static IEnumerator PushToHWCloud(string signUrl, byte[] buffer, Action callback)
|
|
|
{
|
|
|
- ET.Log.Debug("zoya:000" + signUrl);
|
|
|
- // 使用PUT请求上传对象
|
|
|
- HttpWebRequest webRequest = WebRequest.Create(signUrl) as HttpWebRequest;
|
|
|
- webRequest.Method = "PUT";
|
|
|
- ET.Log.Debug("zoya:111" + webRequest);
|
|
|
-
|
|
|
- webRequest.SendChunked = true;
|
|
|
- webRequest.AllowWriteStreamBuffering = false;
|
|
|
- ET.Log.Debug("zoya:222" + webRequest);
|
|
|
-
|
|
|
- using (Stream requestStream = webRequest.GetRequestStream())
|
|
|
+ using (UnityWebRequest www = UnityWebRequest.Put(signUrl, buffer))
|
|
|
{
|
|
|
- ET.Log.Debug("zoya:333" + webRequest);
|
|
|
+ yield return www.SendWebRequest();
|
|
|
|
|
|
- requestStream.Write(buffer, 0, buffer.Length);
|
|
|
+ if (www.result != UnityWebRequest.Result.Success)
|
|
|
+ {
|
|
|
+ Debug.Log(www.error);
|
|
|
+ callback?.Invoke();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Debug.Log("Upload complete!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- HttpWebResponse webResponse = null;
|
|
|
- try
|
|
|
- {
|
|
|
- ET.Log.Debug("zoya:444" + webRequest);
|
|
|
-
|
|
|
- webResponse = webRequest.GetResponse() as HttpWebResponse;
|
|
|
- ET.Log.Debug("zoya:555" + webRequest);
|
|
|
-
|
|
|
- return webResponse.StatusCode.ToString();
|
|
|
- }
|
|
|
- catch (WebException ex)
|
|
|
- {
|
|
|
- webResponse = ex.Response as HttpWebResponse;
|
|
|
- return "";
|
|
|
- }
|
|
|
}
|
|
|
//保存成功后,添加图片至相册
|
|
|
public static async ETTask<long> ReqAddTophoto(string pictureObjectPath, int sourceType)
|
|
@@ -136,46 +119,13 @@ namespace GFGGame
|
|
|
}
|
|
|
public static IEnumerator DownloadFile(PoemPhotoData poemPhotoData)
|
|
|
{
|
|
|
+
|
|
|
using (UnityWebRequest request = UnityWebRequestTexture.GetTexture(poemPhotoData.PictureTempUrl))
|
|
|
{
|
|
|
yield return request.SendWebRequest();
|
|
|
Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
|
|
|
poemPhotoData.Ntexture = new NTexture(texture);
|
|
|
}
|
|
|
- // try
|
|
|
- // {
|
|
|
-
|
|
|
- // HttpWebRequest webRequest = HttpWebRequest.Create(poemPhotoData.PictureTempUrl) as HttpWebRequest;
|
|
|
- // webRequest.Method = "GET";
|
|
|
- // ET.Log.Debug("zoyabbb+Method:" + webRequest.Method);
|
|
|
-
|
|
|
- // HttpWebResponse webResponse = webRequest.GetResponse() as HttpWebResponse;
|
|
|
- // ET.Log.Debug("zoyabbb" + webResponse);
|
|
|
-
|
|
|
- // System.IO.Stream st = webResponse.GetResponseStream();
|
|
|
- // ET.Log.Debug("zoyabbb+st:" + st);
|
|
|
-
|
|
|
- // byte[] bytes;
|
|
|
- // using (var ms = new MemoryStream())
|
|
|
- // {
|
|
|
- // st.CopyTo(ms);
|
|
|
- // bytes = ms.ToArray();
|
|
|
- // }
|
|
|
- // ET.Log.Debug("zoyaccc");
|
|
|
-
|
|
|
- // st.Close();
|
|
|
- // webResponse.Close();
|
|
|
- // webRequest.Abort();
|
|
|
- // ET.Log.Debug("zoyaddd");
|
|
|
- // poemPhotoData.Bytes = bytes;
|
|
|
- // }
|
|
|
- // catch (WebException ex)
|
|
|
- // {
|
|
|
- // ET.Log.Debug("zoyaeee");
|
|
|
-
|
|
|
- // // webResponse = ex.Response as HttpWebResponse;
|
|
|
- // ET.Log.Debug(ex.Response.ToString());
|
|
|
- // }
|
|
|
|
|
|
}
|
|
|
//批量删除玩家相册
|