public static ImageRequest DownloadModGalleryImage(ModProfile profile, string imageFileName, ModGalleryImageSize size) { ImageRequest request = new ImageRequest(); string imageURL = profile.media.GetGalleryImageWithFileName(imageFileName).GetSizeURL(size); UnityWebRequest webRequest = UnityWebRequest.Get(imageURL); webRequest.downloadHandler = new DownloadHandlerTexture(true); var operation = webRequest.SendWebRequest(); operation.completed += (o) => DownloadClient.OnImageDownloadCompleted(operation, request); return(request); }
// ---------[ IMAGE DOWNLOADS ]--------- public static ImageRequest DownloadModLogo(ModProfile profile, LogoSize size) { ImageRequest request = new ImageRequest(); request.isDone = false; string logoURL = profile.logoLocator.GetSizeURL(size); UnityWebRequest webRequest = UnityWebRequest.Get(logoURL); webRequest.downloadHandler = new DownloadHandlerTexture(true); var operation = webRequest.SendWebRequest(); operation.completed += (o) => DownloadClient.OnImageDownloadCompleted(operation, request); return(request); }
public static ImageRequest DownloadImage(string imageURL) { ImageRequest request = new ImageRequest(); request.isDone = false; UnityWebRequest webRequest = UnityWebRequest.Get(imageURL); webRequest.downloadHandler = new DownloadHandlerTexture(true); var operation = webRequest.SendWebRequest(); operation.completed += (o) => DownloadClient.OnImageDownloadCompleted(operation, request); #if DEBUG if (PluginSettings.data.logAllRequests) { string requestHeaders = ""; List <string> requestKeys = new List <string>(APIClient.UNITY_REQUEST_HEADER_KEYS); requestKeys.AddRange(APIClient.MODIO_REQUEST_HEADER_KEYS); foreach (string headerKey in requestKeys) { string headerValue = webRequest.GetRequestHeader(headerKey); if (headerValue != null) { requestHeaders += "\n" + headerKey + ": " + headerValue; } } int timeStamp = ServerTimeStamp.Now; Debug.Log("IMAGE REQUEST SENT" + "\nTimeStamp: [" + timeStamp.ToString() + "] " + ServerTimeStamp.ToLocalDateTime(timeStamp).ToString() + "\nURL: " + webRequest.url + "\nHeaders: " + requestHeaders); } #endif return(request); }
public static ImageRequest DownloadImage(string imageURL) { ImageRequest request = new ImageRequest(); request.isDone = false; UnityWebRequest webRequest = UnityWebRequest.Get(imageURL); webRequest.downloadHandler = new DownloadHandlerTexture(true); var operation = webRequest.SendWebRequest(); operation.completed += (o) => DownloadClient.OnImageDownloadCompleted(operation, request); #if DEBUG DebugUtilities.DebugDownload(operation, LocalUser.instance, null); #endif return(request); }
public static ImageRequest DownloadImage(string imageURL) { ImageRequest request = new ImageRequest(); request.isDone = false; UnityWebRequest webRequest = UnityWebRequest.Get(imageURL); webRequest.downloadHandler = new DownloadHandlerTexture(true); #if DEBUG if (DownloadClient.logAllRequests) { string requestHeaders = ""; List <string> requestKeys = new List <string>(APIClient.UNITY_REQUEST_HEADER_KEYS); requestKeys.AddRange(APIClient.MODIO_REQUEST_HEADER_KEYS); foreach (string headerKey in requestKeys) { string headerValue = webRequest.GetRequestHeader(headerKey); if (headerValue != null) { requestHeaders += "\n" + headerKey + ": " + headerValue; } } Debug.Log("GENERATING DOWNLOAD REQUEST" + "\nURL: " + webRequest.url + "\nHeaders: " + requestHeaders + "\n" ); } #endif var operation = webRequest.SendWebRequest(); operation.completed += (o) => DownloadClient.OnImageDownloadCompleted(operation, request); return(request); }