static void Main(string[] args) { ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback; IUserContentManagementServiceClient ucmService = TypeSafeHttpBuilder <IUserContentManagementServiceClient> .Create() .RegisterDefaultSerializers() .RegisterDotNetHttpClient("https://localhost.:5002/") .RegisterJsonNetSerializer() .Build(); Console.WriteLine("Sending request"); RequestedUrlResponseModel responseModel = ucmService.GetNewWorldUploadUrl(AuthToken) .Result; Console.WriteLine($"URL: {responseModel.UploadUrl}"); IWorldServiceClient worldService = TypeSafeHttpBuilder <IWorldServiceClient> .Create() .RegisterDefaultSerializers() .RegisterDotNetHttpClient("https://localhost.:5003/") .RegisterJsonNetSerializer() .Build(); WorldDownloadURLResponse downloadResponse = worldService.GetWorldDownloadUrl(new WorldDownloadURLRequest(64), AuthToken).Result; Console.WriteLine($"Download URL Response: {downloadResponse.ResultCode} {downloadResponse.DownloadURL}"); Console.ReadKey(); }
void OnGUI() { AccountName = EditorGUILayout.TextField("Account", AccountName); Password = EditorGUILayout.PasswordField("Password", Password); //TODO: Validate scene file SceneObject = EditorGUILayout.ObjectField("Scene", SceneObject, typeof(SceneAsset), false); if (GUILayout.Button("Build World AssetBundle")) { if (!Authenticate()) { Debug.LogError($"Failed to authenticate User: {AccountName}"); return; } //Once authenticated we need to try to build the bundle. ProjectVindictiveAssetbundleBuilder builder = new ProjectVindictiveAssetbundleBuilder(SceneObject); //TODO: Handle uploading build AssetBundleManifest manifest = builder.BuildBundle(); //TODO: Refactor all this crap AssetBundlePath = manifest.GetAllAssetBundles().First(); return; } if (GUILayout.Button("Upload Assetbundle")) { //https://stackoverflow.com/questions/4926676/mono-https-webrequest-fails-with-the-authentication-or-decryption-has-failed ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback; IUserContentManagementServiceClient ucmService = TypeSafeHttpBuilder <IUserContentManagementServiceClient> .Create() .RegisterDefaultSerializers() .RegisterDotNetHttpClient("https://localhost:5002/") .RegisterJsonNetSerializer() .Build(); Thread uploadThread = new Thread(new ThreadStart(async() => { Debug.Log("Recieved URL Response."); //HttpWebRequest httpRequest = WebRequest.Create(ucmService.GetNewWorldUploadUrl(AuthToken).Result.UploadUrl) as HttpWebRequest; HttpWebRequest httpRequest = WebRequest.Create((await ucmService.GetNewWorldUploadUrl(AuthToken)).UploadUrl) as HttpWebRequest; Debug.Log("Built http request with URL"); httpRequest.Method = "PUT"; using (Stream dataStream = httpRequest.GetRequestStream()) { byte[] buffer = new byte[8000]; using (FileStream fileStream = new FileStream(Path.Combine("AssetBundles/temp/", AssetBundlePath), FileMode.Open, FileAccess.Read)) { int bytesRead = 0; while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) > 0) { dataStream.Write(buffer, 0, bytesRead); } } } HttpWebResponse response = httpRequest.GetResponse() as HttpWebResponse; })); uploadThread.Start(); } }