IEnumerator ShowLoadDialogCoroutine() { // Show a load file dialog and wait for a response from user // Load file/folder: file, Initial path: default (Documents), Title: "Load File", submit button text: "Load" yield return(FileBrowser.WaitForLoadDialog(false, @"Assets\Resources\Animations\", "Load Animation", "Load")); // Dialog is closed // Print whether a file is chosen (FileBrowser.Success) // and the path to the selected file (FileBrowser.Result) (null, if FileBrowser.Success is false) Debug.Log(FileBrowser.Success + " " + FileBrowser.Result); if (FileBrowser.Success) { // If a file was chosen, read its bytes via FileBrowserHelpers // Contrary to File.ReadAllBytes, this function works on Android 10+, as well //byte[] bytes = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result) string code = FileBrowserHelpers.ReadTextFromFile(FileBrowser.Result); Anim loadedAnim = new Anim(FileBrowserHelpers.GetFilename(FileBrowser.Result).Replace(".txt", ""), code); //loadedAnim.Code = GetCleanCode(loadedAnim.Code); AnimationData.Instance.AddAnim(loadedAnim); AnimationData.Instance.selectedAnim = loadedAnim; MenuManager.Instance.UpdateAnimations(); MenuManager.Instance.SetSelectedAnimation(loadedAnim.AnimationName); } }
/// <summary> /// Displays File Browser to select a file Location to save the exported glTF file /// </summary> /// <returns>IEnumerator Object</returns> public IEnumerator DisplaySaveCoroutine() { FileBrowser.SingleClickMode = true; yield return(FileBrowser.WaitForSaveDialog(FileBrowser.PickMode.FilesAndFolders, false, null, null, "Select Folder", "Save")); if (FileBrowser.Success) { string returnedPath = FileBrowser.Result[0]; Debug.Log("Export Path : " + returnedPath); var exporter = new GLTFSceneExporter(new[] { _viewerObject.transform }, RetrieveTexturePath); if (FileBrowserHelpers.DirectoryExists(returnedPath)) { string folderName = _loadFileName ?? "ExportedObject"; string finalExportPath = FileBrowserHelpers.CreateFolderInDirectory(returnedPath, folderName); Debug.Log("Final Export Path for empty filename : " + finalExportPath); exporter.SaveGLTFandBin(finalExportPath, folderName); } else { string saveFileName = FileBrowserHelpers.GetFilename(returnedPath); string folderPath = returnedPath.Substring(0, returnedPath.LastIndexOf(saveFileName)); string finalExportPath = FileBrowserHelpers.CreateFolderInDirectory(folderPath, saveFileName); Debug.Log("Final Export Path with given filename : " + finalExportPath); exporter.SaveGLTFandBin(finalExportPath, saveFileName); } } }
/// <summary> /// Returns the paths of all the files present in the folder /// Note - upload size must be less than MaxUploadSize /// </summary> /// <param name="folderPath">Folder Path</param> /// <param name="uploadSize">Passint the size of all file in Folder as out param</param> /// <returns>List of all the file paths present in given folder</returns> List <string> GetUploadFileList(string folderPath, out long uploadSize) { List <string> filePaths = new List <string>(); Stack <string> dirs = new Stack <string>(); long uploadLength = 0; if (FileBrowserHelpers.DirectoryExists(folderPath)) { dirs.Push(folderPath); } while (dirs.Count > 0) { string currentDir = dirs.Pop(); FileSystemEntry[] allEntries = FileBrowserHelpers.GetEntriesInDirectory(currentDir); foreach (FileSystemEntry entry in allEntries) { if (entry.IsDirectory) { dirs.Push(entry.Path); } else { filePaths.Add(entry.Path); uploadLength += FileBrowserHelpers.GetFilesize(entry.Path); Debug.Log("File : " + entry.Path); } } } uploadSize = uploadLength; return(filePaths); }
private async void ReadFB2File(string path) { string fileName = FileBrowserHelpers.GetFilename(path); string text = FileBrowserHelpers.ReadTextFromFile(path); FB2File file = await new FB2Reader().ReadAsync(text); var lines = await _fB2SampleConverter.ConvertAsync(file); string finalText = _fB2SampleConverter.GetLinesAsText(); byte[] imageData = _fB2SampleConverter.GetCoverImageData(); string imagePath = Application.persistentDataPath + _targetFolder + fileName + ".jpg";; try { File.WriteAllBytes(imagePath, imageData); Debug.Log("Image is saved. Path: " + imagePath); } catch { Debug.LogError("Loading image is error!"); } imagePath = imagePath.Replace("/", "\\"); string filePath = (Application.persistentDataPath + _targetFolder + fileName).Replace("/", "\\"); FileData newBook = new FileData(fileName, filePath, imagePath, FileData.FileType.Book); SaveFile(newBook, finalText); }
/// ボタンをクリックした時の処理 public void OnClick() { // Open file with filter var extensions = new [] { new ExtensionFilter("VRM Files", "vrm"), new ExtensionFilter("All Files", "*"), }; var paths = StandaloneFileBrowser.OpenFilePanel("Open File", "", extensions, true); if (paths.Length > 0) { var file = paths[0]; byte[] bytes = FileBrowserHelpers.ReadBytesFromFile(file); var context = new VRMImporterContext(); try { context.ParseGlb(bytes); msg.text = "Import VRM finished successfully. (" + file + ")"; var meta = context.ReadMeta(false); //引数をTrueに変えるとサムネイルも読み込みます Debug.LogFormat("meta: title:{0}", meta.Title); //同期処理で読み込みます context.Load(); //読込が完了するとcontext.RootにモデルのGameObjectが入っています Destroy(instance); instance = context.Root; instance.transform.position = new Vector3(0, 0, 0); instance.transform.rotation = Quaternion.Euler(0, 0, 0); instance.AddComponent <PMXExporter>(); context.ShowMeshes(); } catch (Exception ex) { msg.text = "Error: " + ex.Message; } } }
IEnumerator ShowLoadDialogFolderCoroutine() { // Show a load file dialog and wait for a response from user // Load file/folder: file, Initial path: default (Documents), Title: "Load File", submit button text: "Load" yield return(FileBrowser.WaitForLoadDialog(true, null, "Select Folder", "Select")); // Dialog is closed // Print whether a file is chosen (FileBrowser.Success) // and the path to the selected file (FileBrowser.Result) (null, if FileBrowser.Success is false) Debug.Log(FileBrowser.Success + " " + FileBrowser.Result); if (FileBrowser.Success) { sourchPath = FileBrowser.Result; string strCh = (characterNo < 10) ? ("0" + characterNo.ToString()) : characterNo.ToString(); string strFr = (frameNo < 10) ? ("0" + frameNo.ToString()) : frameNo.ToString(); string outlineFileStr = "//" + string.Format(outlineFilePrefix, strCh, strFr) + "." + fileSuffix; string originalFileStr = "//" + string.Format(originalFilePrefix, strCh, strFr) + "." + fileSuffix; var photofileContent = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result + originalFileStr); var outlinefileContent = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result + outlineFileStr); photoToSwap.sprite.texture.LoadImage(photofileContent); outlineToSwap.sprite.texture.LoadImage(outlinefileContent); } }
IEnumerator ShowLoadDialogCoroutine() { // Show a load file dialog and wait for a response from user // Load file/folder: both, Allow multiple selection: true // Initial path: default (Documents), Initial filename: empty // Title: "Load File", Submit button text: "Load" yield return(FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.FilesAndFolders, true, null, null, "Load Files and Folders", "Load")); // Dialog is closed // Print whether the user has selected some files/folders or cancelled the operation (FileBrowser.Success) Debug.Log(FileBrowser.Success); if (FileBrowser.Success) { // Print paths of the selected files (FileBrowser.Result) (null, if FileBrowser.Success is false) for (int i = 0; i < FileBrowser.Result.Length; i++) { Debug.Log(FileBrowser.Result[i]); } // Read the bytes of the first file via FileBrowserHelpers // Contrary to File.ReadAllBytes, this function works on Android 10+, as well byte[] bytes = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result[0]); // Or, copy the first file to persistentDataPath string destinationPath = Path.Combine(Application.persistentDataPath, FileBrowserHelpers.GetFilename(FileBrowser.Result[0])); FileBrowserHelpers.CopyFile(FileBrowser.Result[0], destinationPath); previewImage.sprite = LoadSprite(destinationPath); } }
IEnumerator ShowLoadDialogCoroutine(Toggle toggle) { yield return(FileBrowser.WaitForLoadDialog(false, null, "Load File", "Load")); Debug.Log(FileBrowser.Success + " " + FileBrowser.Result); if (FileBrowser.Success) { byte[] bytes = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result); Texture2D tex = new Texture2D(1024, 1024); tex.LoadImage(bytes); if (tex.height > 1024 || tex.height < 1024 || tex.width > 1024 || tex.width < 1024) { DisplayError("Invalid Map Height or Length, dimenstion must be 1024x1024"); } if (toggle.group.name == Selection.HeightSelect.ToString()) { customHeightmap = tex; } else if (toggle.group.name == Selection.SoilSelect.ToString()) { customSoilMap = tex; } else if (toggle.group.name == Selection.VegetationSelect.ToString()) { customVegetationMap = tex; } } }
/// <summary> /// Uploads the files present in the folder selected by the user /// </summary> /// <param name="folderPath">Path of folder</param> /// <returns></returns> IEnumerator UploadFolderToAmazonS3(string folderPath) { bool errorOccured = false; string errorMsg = null; string rootName = FileBrowserHelpers.GetFilename(folderPath); List <string> uploadFileList = GetUploadFileList(folderPath, out long uploadSize); if (uploadSize > MaxUploadFileSize) { DisplayUploadErrorMessage("File size is too large. It must be less than 50MB."); yield break; } if (uploadFileList.Count > 1) { int numberOfFiles = uploadFileList.Count; float index = 0; float uploadPercentage; string key, progress; MessageFields uploadMsgFields = DisplayUploadProgressMessage(); foreach (string file in uploadFileList) { uploadPercentage = (index / numberOfFiles) * 100; progress = "Progress : " + Mathf.Round(uploadPercentage).ToString() + "%"; uploadMsgFields.MessageDetails("Upload Progress ...", progress); key = file.Substring(file.LastIndexOf(rootName)); key = key.Replace("\\", "/"); yield return(GetPreSignedRequest(key, file, false, (e, m) => { errorOccured = e; errorMsg = m; })); if (errorOccured) { break; } index++; } DestroyUploadProgressMessage(uploadMsgFields); if (errorOccured) { DisplayUploadErrorMessage(errorMsg); yield break; } if (gltfUrl != null) { yield return(PushUrlToDatabase(gltfUrl)); } } else if (uploadFileList.Count == 1) { string filePath = uploadFileList[0]; string key = filePath.Substring(filePath.LastIndexOf(rootName)); key = key.Replace("\\", "/"); yield return(GetPreSignedRequest(key, filePath, true, (e, m) => { })); } else { DisplayUploadErrorMessage("Folder is Empty."); } }
// Warning: paths returned by FileBrowser dialogs do not contain a trailing '\' character // Warning: FileBrowser can only show 1 dialog at a time public void OpenDialog() { // Set filters (optional) // It is sufficient to set the filters just once (instead of each time before showing the file browser dialog), // if all the dialogs will be using the same filters FileBrowser.SetFilters(true, new FileBrowser.Filter("RFP File", ".rfp")); // Set default filter that is selected when the dialog is shown (optional) // Returns true if the default filter is set successfully // In this case, set Images filter as the default filter FileBrowser.SetDefaultFilter(".rfp"); // Set excluded file extensions (optional) (by default, .lnk and .tmp extensions are excluded) // Note that when you use this function, .lnk and .tmp extensions will no longer be // excluded unless you explicitly add them as parameters to the function FileBrowser.SetExcludedExtensions(".lnk", ".tmp", ".zip", ".rar", ".exe"); // Add a new quick link to the browser (optional) (returns true if quick link is added successfully) // It is sufficient to add a quick link just once // Name: Users // Path: C:\Users // Icon: default (folder icon) FileBrowser.AddQuickLink("Users", "C:\\Users", null); // Show a save file dialog // onSuccess event: not registered (which means this dialog is pretty useless) // onCancel event: not registered // Save file/folder: file, Allow multiple selection: false // Initial path: "C:\", Initial filename: "Screenshot.png" // Title: "Save As", Submit button text: "Save" // FileBrowser.ShowSaveDialog( null, null, FileBrowser.PickMode.Files, false, "C:\\", "Screenshot.png", "Save As", "Save" ); // Show a select folder dialog // onSuccess event: print the selected folder's path // onCancel event: print "Canceled" // Load file/folder: folder, Allow multiple selection: false // Initial path: default (Documents), Initial filename: empty // Title: "Select Folder", Submit button text: "Select" string initialPath = null; string initialFile = null; if (FileBrowserHelpers.FileExists(fileInput.text)) { initialPath = FileBrowserHelpers.GetDirectoryName(fileInput.text); initialFile = FileBrowserHelpers.GetFilename(fileInput.text); } if (FileBrowserHelpers.DirectoryExists(fileInput.text)) { initialPath = fileInput.text; } FileBrowser.ShowLoadDialog((paths) => { Debug.Log("Selected: " + paths[0]); fileInput.text = paths[0]; }, () => { Debug.Log("Canceled file open"); }, FileBrowser.PickMode.Files, false, initialPath, initialFile); // Coroutine example //StartCoroutine(ShowLoadDialogCoroutine()); }
IEnumerator ShowLoadDialogCoroutine() { yield return(FileBrowser.WaitForLoadDialog(false, null, "Load File", "Load")); if (FileBrowser.Success) { byte[] bytes = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result); AddFile(FileBrowser.Result); } }
public void ExportClicked() { SimpleFileBrowser.FileBrowser.ShowLoadDialog((paths) => { string sourcePath = Path.Combine(Application.persistentDataPath, "StorageDatabase.FILE"); string destinationDirectory = FileBrowserHelpers.GetDirectoryName(FileBrowser.Result[FileBrowser.Result.Length - 1]); string destinationPath = Path.Combine(destinationDirectory, "StorageDatabase.FILE"); FileBrowserHelpers.CopyFile(sourcePath, destinationPath); }, null, SimpleFileBrowser.FileBrowser.PickMode.Folders); }
IEnumerator ShowLoadDialogCoroutine() { yield return(FileBrowser.WaitForSaveDialog(false, false, null, "Export Script", "Export")); Debug.Log(FileBrowser.Success); if (FileBrowser.Success) { FileBrowserHelpers.WriteBytesToFile(FileBrowser.Result[0], Encoding.UTF8.GetBytes(CodeBox.text)); } }
void ReadFile(string path) { if (path != "") { //byte[] bt = FileBrowserHelpers.ReadBytesFromFile(path); //Designer.PGdata = System.Text.Encoding.ASCII.GetString(bt); Designer.PGdata = FileBrowserHelpers.ReadTextFromFile(path); Designer.LoadFromString(); } }
IEnumerator ShowEnvLoadDialogCoroutine() { yield return(FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.FilesAndFolders, false, Application.dataPath + "/MatsJson/", null, "Load environment", "Load")); if (FileBrowser.Success) { string destinationPath = FileBrowser.Result[0]; DeserializeField(FileBrowserHelpers.GetDirectoryName(FileBrowser.Result[0]), FileBrowserHelpers.GetFilename(FileBrowser.Result[0])); } }
IEnumerator ShowLoadFieldDialogCoroutine() { yield return(FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.FilesAndFolders, false, Application.dataPath + "/CustomFields/", null, "Load field", "Load")); if (FileBrowser.Success) { string destinationPath = FileBrowser.Result[0]; fileImage = FileBrowserHelpers.GetFilename(FileBrowser.Result[0]); LoadFieldToPath(destinationPath); } }
public void ImportClicked() { SimpleFileBrowser.FileBrowser.SetFilters(false, new SimpleFileBrowser.FileBrowser.Filter( "Databases", ".DB", ".DBS", ".SQL", ".SQLITE3", ".SQLITE3", ".FILE")); SimpleFileBrowser.FileBrowser.ShowLoadDialog((paths) => { string destinationPath = Path.Combine(Application.persistentDataPath, FileBrowserHelpers.GetFilename(FileBrowser.Result[0])); FileBrowserHelpers.CopyFile(FileBrowser.Result[0], destinationPath); }, null, SimpleFileBrowser.FileBrowser.PickMode.Files); }
IEnumerator _MobileFileBrowserSetHome() { yield return(SimpleFileBrowser.FileBrowser.WaitForLoadDialog(FileBrowser.PickMode.Folders, true, getPalettePathFolder(), null, "Set Home Path Folder", "Load")); androidSaveLoadBackground.SetActive(false); if (SimpleFileBrowser.FileBrowser.Success) { //Because F%^$ing Android refuses to keep file IO simple, with their F!@# stupid SAF system string realpath = FileBrowserHelpers.GetDirectoryName(SimpleFileBrowser.FileBrowser.Result[0] + SLASH + "idontexist.csv"); setHomePath(realpath); } }
/// <summary> /// Uploads the File/Folder to AmazonS3 /// Determines if the user selected path is a file or Folder and calls appropriate Coroutines /// </summary> /// <param name="dataPath">User Selected path for upload</param> public void UploadToAmazonS3(string dataPath) { if (FileBrowserHelpers.DirectoryExists(dataPath)) { StartCoroutine(UploadFolderToAmazonS3(dataPath)); } else { string key = FileBrowserHelpers.GetFilename(dataPath); StartCoroutine(GetPreSignedRequest(key, dataPath, true, (e, m) => { })); } }
void WriteFile(string path, string filename) { string f; f = FileBrowserHelpers.CreateFileInDirectory(path, filename + ".waterline"); Designer.SaveToString(); FileBrowserHelpers.WriteTextToFile(f, Designer.PGdata); f = FileBrowserHelpers.CreateFileInDirectory(path, filename + ".png"); byte[] bt = Designer.MakeThumbBytes(512); FileBrowserHelpers.WriteBytesToFile(f, bt); }
void OpenAndReadFile(string path) { Debug.Log(path); if (path != "") { Text tx = GameObject.Find("DebugText").GetComponent <Text>(); byte[] bt = FileBrowserHelpers.ReadBytesFromFile(path); tx.text = path + "\n"; tx.text += System.Text.Encoding.ASCII.GetString(bt); } }
public Sprite LoadSprite(string path) { byte[] bytes = new byte[0]; Texture2D tex = new Texture2D(2, 2); bytes = FileBrowserHelpers.ReadBytesFromFile(path); tex.LoadImage(bytes); Rect rec = new Rect(0, 0, tex.width, tex.height); Sprite sprite = Sprite.Create(tex, rec, new Vector2(0.5f, 0.5f), 100); return(sprite); }
IEnumerator ShowSaveDialogCoroutine(string data) { // Show a Save Dialog and wait for response from users yield return(FileBrowser.WaitForSaveDialog(false, false, null, "Save", "Save")); // Dialog is closed Debug.Log(FileBrowser.Success); if (FileBrowser.Success) { Debug.Log(FileBrowser.Result[0]); FileBrowserHelpers.WriteTextToFile(FileBrowser.Result[0], data); } }
private void UpdateFilesListUI() { var appManager = AppManager.Instance; int fileIndex = _currentFileIndex; for (int i = 0; i < _filesSlots.Length; i++) { if (appManager.FilesData == null || fileIndex >= appManager.FilesData.Files.Count || appManager.FilesData.Files[fileIndex] == null || appManager.FilesData.Files[fileIndex].Path == string.Empty) { _filesSlots[i].gameObject.SetActive(false); continue; } var file = appManager.FilesData.Files[fileIndex]; var slot = _filesSlots[i]; if (!FileBrowserHelpers.FileExists(file.Path)) { appManager.FilesData.Files.Remove(file); appManager.SaveFilesData(); _filesSlots[i].gameObject.SetActive(false); continue; } Sprite cover = null; if (file.CoverImagePath != string.Empty) { if (!FileBrowserHelpers.FileExists(file.CoverImagePath)) { file.CoverImagePath = string.Empty; appManager.SaveFilesData(); } else { cover = appManager.LoadSprite(file.CoverImagePath); } } UnityAction openFile = new UnityAction(() => { OpenFile(file); }); slot.Init(cover, file.Name, openFile); fileIndex++; } }
IEnumerator SaveJsonCoroutine(string data) { FileBrowser.Filter[] filters = new FileBrowser.Filter[1]; filters[0] = new FileBrowser.Filter("JSON files", ".json"); FileBrowser.SetFilters(true, filters); FileBrowser.SetDefaultFilter(".json"); yield return(FileBrowser.WaitForSaveDialog(false, @"Assets\Resources\", "Uloz ulohu", "Uloz")); if (FileBrowser.Success) { string path = FileBrowser.Result; string fileName = FileBrowserHelpers.GetFilename(FileBrowser.Result); File.WriteAllText(path, data); } }
public void SaveFile(FileData file, string text = null) { if (file == null) { string name = DateTime.Now.ToShortDateString() + "_" + DateTime.Now.ToLongTimeString().Replace(":", "_"); string path = Application.persistentDataPath + _targetFolder; try { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } catch (IOException ex) { Debug.Log(ex.Message); } path = path.Replace("/", "\\"); path += name + ".txt"; file = new FileData(name, path, String.Empty, FileData.FileType.UserFile); } try { if (text != null) { FileBrowserHelpers.WriteTextToFile(file.Path, text); } if (!FilesData.Files.Contains(file)) { FilesData.Files.Add(file); } SaveFilesData(); filesListChanged?.Invoke(); Debug.Log("File is saved. Path: " + file.Path); } catch { Debug.Log("Saving file is end error."); } }
IEnumerator ShowLoadDialogCoroutine() { yield return FileBrowser.WaitForLoadDialog(false, null, "Select Sound", "Select"); pathText.text = FileBrowser.Result; if (FileBrowser.Success) { byte[] SoundFile = FileBrowserHelpers.ReadBytesFromFile(FileBrowser.Result); yield return SoundFile; audioSource.clip = NAudioPlayer.FromMp3Data(SoundFile); audioSource.Play(); } }
IEnumerator ShowLoadDialogCoroutine() { // Show a load file dialog and wait for a response from user // Load file/folder: file, Initial path: default (Documents), Title: "Load File", submit button text: "Load" yield return(FileBrowser.WaitForLoadDialog(false, @"Assets\", "Load Object", "Load")); // Dialog is closed // Print whether a file is chosen (FileBrowser.Success) // and the path to the selected file (FileBrowser.Result) (null, if FileBrowser.Success is false) Debug.Log(FileBrowser.Success + " " + FileBrowser.Result); if (FileBrowser.Success) { IndexedFace.Instance.UpdateModel(FileBrowser.Result, FileBrowserHelpers.GetFilename(FileBrowser.Result).Replace(".obj", "")); } }
IEnumerator SaveAnimationCoroutine(Anim newAnim) { yield return(FileBrowser.WaitForSaveDialog(false, @"Assets\Resources\Animations\", "Save Animation", "Save")); if (FileBrowser.Success) { string path = FileBrowser.Result; string fileName = FileBrowserHelpers.GetFilename(FileBrowser.Result); newAnim.AnimationName = fileName.Replace(".txt", ""); //FileBrowserHelpers.CreateFileInDirectory(@"Assets\Resources\Animations\",fileName); HandleTextFile.WriteString(path, newAnim.Code /*GetCleanCode(newAnim.Code)*/); AnimationData.Instance.AddAnim(newAnim); AnimationData.Instance.selectedAnim = newAnim; MenuManager.Instance.UpdateAnimations(); MenuManager.Instance.SetSelectedAnimation(newAnim.AnimationName); } }
/// <summary> /// Uploads a single file to the server. Not used in case of upload to AmazonS3 /// Note - As the backend server supports only upload to AmazonS3 this is never called /// </summary> /// <param name="uploadFilePath">Path of file to be uploaded</param> /// <param name="deleteTempFile">Path of temporary Zip file</param> /// <returns></returns> private IEnumerator UploadFileToServer(string uploadFilePath, bool deleteTempFile) { List <IMultipartFormSection> formData = new List <IMultipartFormSection>(); string fileName = FileBrowserHelpers.GetFilename(uploadFilePath); byte[] fileData = FileBrowserHelpers.ReadBytesFromFile(uploadFilePath); formData.Add(new MultipartFormFileSection("Object", fileData, fileName, "application/octet-stream")); using (UnityWebRequest uwr = UnityWebRequest.Post(amazonS3ServerBackend + "/fileupload", formData)) { uwr.SendWebRequest(); MessageFields uploadMsgFields = DisplayUploadProgressMessage(); StartCoroutine(CheckUploadConnection(uwr)); while (!uwr.isDone) { string progress = "Progress : " + Mathf.Round(uwr.uploadProgress * 100).ToString() + "%"; uploadMsgFields.MessageDetails("Upload Progress ...", progress); if (uwr.isNetworkError || uwr.isHttpError) { yield break; } yield return(null); } if (uwr.result != UnityWebRequest.Result.Success) { DestroyUploadProgressMessage(uploadMsgFields); if (deleteTempFile && FileBrowserHelpers.FileExists(uploadFilePath)) { FileBrowserHelpers.DeleteFile(uploadFilePath); Debug.Log("Temp File deleted after Error"); } DisplayUploadErrorMessage(uwr.error); } else { DestroyUploadProgressMessage(uploadMsgFields); if (deleteTempFile && FileBrowserHelpers.FileExists(uploadFilePath)) { FileBrowserHelpers.DeleteFile(uploadFilePath); Debug.Log("Temp File deleted"); } } } }