diff --git a/RuntimeFilesDownloader/RuntimeFilesDownloader.uplugin b/RuntimeFilesDownloader/RuntimeFilesDownloader.uplugin index eedce4a..2009230 100644 --- a/RuntimeFilesDownloader/RuntimeFilesDownloader.uplugin +++ b/RuntimeFilesDownloader/RuntimeFilesDownloader.uplugin @@ -31,7 +31,6 @@ "BlacklistPlatforms": [ "XboxOne", "PS4", - "HTML5", "TVOS", "Switch" ] diff --git a/RuntimeFilesDownloader/Source/RuntimeFilesDownloader/Private/RuntimeFilesDownloaderLibrary.cpp b/RuntimeFilesDownloader/Source/RuntimeFilesDownloader/Private/RuntimeFilesDownloaderLibrary.cpp index b899af3..9793c50 100644 --- a/RuntimeFilesDownloader/Source/RuntimeFilesDownloader/Private/RuntimeFilesDownloaderLibrary.cpp +++ b/RuntimeFilesDownloader/Source/RuntimeFilesDownloader/Private/RuntimeFilesDownloaderLibrary.cpp @@ -30,10 +30,11 @@ URuntimeFilesDownloaderLibrary* URuntimeFilesDownloaderLibrary::DownloadFile(con FileUrl = URL; FileSavePath = SavePath; - TSharedRef< IHttpRequest, ESPMode::ThreadSafe > HttpRequest = FHttpModule::Get().CreateRequest(); + TSharedRef< IHttpRequest > HttpRequest = FHttpModule::Get().CreateRequest(); HttpRequest->SetVerb("GET"); HttpRequest->SetURL(URL); + HttpRequest->SetHeader("Content-Type", TEXT("application/octet-stream")); HttpRequest->OnProcessRequestComplete().BindUObject(this, &URuntimeFilesDownloaderLibrary::OnReady_Internal); HttpRequest->OnRequestProgress().BindUObject(this, &URuntimeFilesDownloaderLibrary::OnProgress_Internal); @@ -46,8 +47,12 @@ URuntimeFilesDownloaderLibrary* URuntimeFilesDownloaderLibrary::DownloadFile(con void URuntimeFilesDownloaderLibrary::OnProgress_Internal(FHttpRequestPtr Request, int32 BytesSent, int32 BytesReceived) { - int32 FullSize = Request->GetContentLength(); - OnProgress.Broadcast(BytesSent, BytesReceived, FullSize); + FHttpResponsePtr Response = Request->GetResponse(); + if (Response.IsValid()) + { + int32 FullSize = Response->GetContentLength(); + OnProgress.Broadcast(BytesSent, BytesReceived, FullSize); + } } void URuntimeFilesDownloaderLibrary::OnReady_Internal(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) diff --git a/RuntimeFilesDownloader/Source/RuntimeFilesDownloader/Public/RuntimeFilesDownloaderLibrary.h b/RuntimeFilesDownloader/Source/RuntimeFilesDownloader/Public/RuntimeFilesDownloaderLibrary.h index d59647a..bb9aa10 100644 --- a/RuntimeFilesDownloader/Source/RuntimeFilesDownloader/Public/RuntimeFilesDownloaderLibrary.h +++ b/RuntimeFilesDownloader/Source/RuntimeFilesDownloader/Public/RuntimeFilesDownloaderLibrary.h @@ -5,6 +5,7 @@ #include "Http.h" #include "Misc/Paths.h" #include "HAL/PlatformFilemanager.h" +#include "GenericPlatform/GenericPlatformFile.h" #include "RuntimeFilesDownloaderLibrary.generated.h" /**