private IEnumerator DownloadFile(ES3Settings settings, string user, string password, long timestamp) { Reset(); var form = CreateWWWForm(); form.AddField("apiKey", apiKey); form.AddField("getFile", settings.path); form.AddField("user", GetUser(user, password)); if (timestamp > 0) { form.AddField("timestamp", timestamp.ToString()); } using (var webRequest = UnityWebRequest.Post(url, form)) { yield return(SendWebRequest(webRequest)); if (!HandleError(webRequest, false)) { if (webRequest.downloadedBytes > 0) { ES3.SaveRaw(webRequest.downloadHandler.data, settings); } else { error = string.Format("File {0} was not found on the server.", settings.path); errorCode = 3; } } } isDone = true; }
/// <summary>Saves a Texture2D as a PNG or JPG, depending on the file extension used for the filePath.</summary> /// <param name="texture">The Texture2D we want to save as a JPG or PNG.</param> /// <param name="settings">The settings we want to use to override the default settings.</param> public static void SaveImage(Texture2D texture, ES3Settings settings) { // Get the file extension to determine what format we want to save the image as. string extension = ES3IO.GetExtension(settings.path).ToLower(); if (string.IsNullOrEmpty(extension)) { throw new System.ArgumentException("File path must have a file extension when using ES3.SaveImage."); } byte[] bytes; if (extension == ".jpg" || extension == ".jpeg") { bytes = texture.EncodeToJPG(); } else if (extension == ".png") { bytes = texture.EncodeToPNG(); } else { throw new System.ArgumentException("File path must have extension of .png, .jpg or .jpeg when using ES3.SaveImage."); } ES3.SaveRaw(bytes, settings); }
public override void Enter() { if (useBase64Encoding.Value) { ES3.SaveRaw(System.Convert.FromBase64String(str.Value) + (appendNewline.Value ? "\n" : ""), GetSettings()); } else { ES3.SaveRaw(str.Value + (appendNewline.Value ? "\n" : ""), GetSettings()); } }
public override void Enter() { if (useBase64Encoding.Value) { ES3.SaveRaw(System.Convert.FromBase64String(str.Value), GetSettings()); } else { ES3.SaveRaw(str.Value, GetSettings()); } }
public void SaveLogs() { print("SAVING"); ES3.SaveRaw(rawStrOut, logTxtPath); sheet.Save(logResultsCsvPath); }