|
@@ -1,3 +1,4 @@
|
|
|
+using LitJson;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
@@ -53,16 +54,23 @@ public class DownLoadItem : MonoBehaviour
|
|
|
|
|
|
public System.Collections.IEnumerator DownloadFile()
|
|
|
{
|
|
|
- string url = HttpAction.baseurl + HttpAction.file_download;
|
|
|
+ string url = HttpAction.baseurl + HttpAction.file_download ;
|
|
|
if (UserInfo.Instance.is20)
|
|
|
{
|
|
|
url = HttpAction.baseurl + HttpAction.file_download;
|
|
|
}
|
|
|
+ Debug.Log(url);
|
|
|
using (UnityWebRequest webRequest = new UnityWebRequest(url, "POST"))
|
|
|
{
|
|
|
- byte[] bodyRaw = Encoding.UTF8.GetBytes(downLoadPath);
|
|
|
+ SendMaterials sendImage = new SendMaterials();
|
|
|
+ sendImage.url = downLoadPath;
|
|
|
+ string jsonImage = JsonMapper.ToJson(sendImage);
|
|
|
+ byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonImage);
|
|
|
webRequest.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
|
|
|
+ webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
|
|
|
webRequest.SetRequestHeader("authorization", UserInfo.Instance.Token);
|
|
|
+ webRequest.SetRequestHeader("Content-Type", "application/json");
|
|
|
+
|
|
|
webRequest.SendWebRequest();
|
|
|
|
|
|
while (!webRequest.isDone)
|
|
@@ -90,6 +98,19 @@ public class DownLoadItem : MonoBehaviour
|
|
|
callback?.Invoke(isDownLoad);
|
|
|
}
|
|
|
}
|
|
|
+ Dictionary<string, string> requestHeader = new Dictionary<string, string>();
|
|
|
+ public void initHead()
|
|
|
+ {
|
|
|
+ requestHeader.Clear();
|
|
|
+ if (UserInfo.Instance.Token != "" && UserInfo.Instance.Token != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ Debug.Log("ADD Token");
|
|
|
+ requestHeader.Add("authorization", UserInfo.Instance.Token);
|
|
|
+ }
|
|
|
+ requestHeader.Add("Content-Type", "application/json");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void OnDestroy()
|
|
|
{
|