1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using Agora.Rtc.LitJson;
- using UnityEngine;
- using UnityEngine.UI;
- public class UpLoadmageItem : MonoBehaviour
- {
- public string path;
- string uuid ;
- public JsonData fildData ;
- public void init(Texture2D texture2D,string str)
- {
- this.transform.GetComponent<RawImage>().texture = texture2D;
- string filePath = str;
- string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
- uuid = fileNameWithoutExtension+"_"+GetFormattedDateTime();
- string fileName = uuid+".png";
- string objecName = "workorder/"+int.Parse(ChuLiItemManager.ChooseData["id"].ToString())+"/";
-
- JsonData jData = new JsonData();
- byte[] data = texture2D.EncodeToPNG();
- jData["size"] = data.Length;
- jData["ext"] = "jpg";
- jData["name"] = fileName;
- JsonData fileData = new JsonData();
- fileData["filePath"] = filePath;
- fileData["fileSize"] = data.Length;
- fileData["fileName"] = fileName;
-
- fileData["objectName"] = objecName;
- fildData = fileData;
- this.path = objecName+fileName;
- }
- string GetFormattedDateTime()
- {
- DateTime now = DateTime.Now;
- return now.ToString("yyyyMMddHHmm");
-
-
- }
- public void startUpLoad(Action<bool> uploadcallback)
- {
-
- DownLoadXRManager.PutFile(fildData["filePath"].ToString(), fildData["fileName"].ToString(), fildData["objectName"].ToString() + fildData["fileName"].ToString(),uuid, int.Parse(fildData["fileSize"].ToString()), msg =>
- {
- uploadcallback.Invoke(true);
- Debug.Log(" 文件上传成功 " + msg);
- });
-
- }
- public void delete()
- {
- BaoGaoUpLoadManager.Instance.itemlist.Remove(this);
- Destroy(this.transform.GetComponent<RawImage>().texture);
- Destroy(this.gameObject);
- }
- }
|