Libcurl FTP-Download incomplete

j.windgassen
Wed, 14 Jul 2021 04:30:28 +0000
Getting Started & Setup

I didn’t manage to get it working in the end (I suspect it’s an Unreal-Related Bug), but I found another way using the included Unreal HTTP Module:

FString Path = ...

// Create the Callback when the HTTP-Request has finished
auto OnRequestComplete = [Path](FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
	if (bWasSuccessful) {
		FFileHelper::SaveArrayToFile(Response->GetContent(), *Path);
		UE_LOG(LogTemp, Log, TEXT("Successfully downloaded the file to '%s'"), *Path)
	} else {
		UE_LOG(LogTemp, Warning, TEXT("Error downloading the file (See EHttpResponseCodes): %s"), Response->GetResponseCode())
	}
};


// Create a HTTP-Request and Fetch the file
TSharedRef<IHttpRequest, ESPMode::ThreadSafe> Request = FHttpModule::Get().CreateRequest();
Request->SetVerb("GET");
Request->SetURL(URL);
Request->OnProcessRequestComplete().BindLambda(OnRequestComplete);

Request->ProcessRequest();

2 posts - 1 participant