录屏
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Script;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
@@ -511,5 +512,37 @@ namespace Stary.Evo
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static async UniTask Upload(string filePath, string serverBaseUrl, string meetingId, string userId,
|
||||
MainPanel.UsersItem host,
|
||||
List<MainPanel.UsersItem> participants)
|
||||
{
|
||||
var bytes = File.ReadAllBytes(filePath);
|
||||
var fileName = Path.GetFileName(filePath);
|
||||
|
||||
var ext = Path.GetExtension(fileName).ToLowerInvariant();
|
||||
var mimeType = ext == ".webm" ? "video/webm" : "video/mp4";
|
||||
|
||||
|
||||
var form = new List<IMultipartFormSection>
|
||||
{
|
||||
new MultipartFormDataSection("meetingId", meetingId),
|
||||
new MultipartFormDataSection("userId", userId),
|
||||
new MultipartFormDataSection("filename", fileName),
|
||||
new MultipartFormFileSection("recording", bytes, fileName, mimeType),
|
||||
new MultipartFormDataSection("host", JsonConvert.SerializeObject(host)),
|
||||
new MultipartFormDataSection("participants", JsonConvert.SerializeObject(participants))
|
||||
};
|
||||
|
||||
using var request = UnityWebRequest.Post($"{serverBaseUrl}/api/recordings", form);
|
||||
request.timeout = 300;
|
||||
request.certificateHandler = new SelfSignedCertHandler(certificateData);
|
||||
await request.SendWebRequest();
|
||||
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
Debug.LogError($"上传失败: {request.error}, body={request.downloadHandler.text}");
|
||||
else
|
||||
Debug.Log($"上传成功: {request.downloadHandler.text}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user