本文整理汇总了C++中FHttpResponsePtr::GetContentLength方法的典型用法代码示例。如果您正苦于以下问题:C++ FHttpResponsePtr::GetContentLength方法的具体用法?C++ FHttpResponsePtr::GetContentLength怎么用?C++ FHttpResponsePtr::GetContentLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FHttpResponsePtr
的用法示例。
在下文中一共展示了FHttpResponsePtr::GetContentLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleImageRequest
void UAsyncTaskDownloadImage::HandleImageRequest(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
{
#if !UE_SERVER
RemoveFromRoot();
if ( bSucceeded && HttpResponse.IsValid() && HttpResponse->GetContentLength() > 0 )
{
IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>(FName("ImageWrapper"));
IImageWrapperPtr ImageWrappers[3] =
{
ImageWrapperModule.CreateImageWrapper(EImageFormat::PNG),
ImageWrapperModule.CreateImageWrapper(EImageFormat::JPEG),
ImageWrapperModule.CreateImageWrapper(EImageFormat::BMP),
};
for ( auto ImageWrapper : ImageWrappers )
{
if ( ImageWrapper.IsValid() && ImageWrapper->SetCompressed(HttpResponse->GetContent().GetData(), HttpResponse->GetContentLength()) )
{
const TArray<uint8>* RawData = NULL;
if ( ImageWrapper->GetRaw(ERGBFormat::BGRA, 8, RawData) )
{
if ( UTexture2D* Texture = UTexture2D::CreateTransient(ImageWrapper->GetWidth(), ImageWrapper->GetHeight()) )
{
WriteRawToTexture(Texture, *RawData);
OnSuccess.Broadcast(Texture);
return;
}
}
}
}
}
OnFail.Broadcast(nullptr);
#endif
}
示例2: HandleFileRequest
void UBPDownloader::HandleFileRequest(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
{
RemoveFromRoot();
if (bSucceeded && HttpResponse.IsValid() && HttpResponse->GetContentLength() > 0)
{
TArray<uint8> data = HttpResponse->GetContent();
if (!FFileHelper::SaveArrayToFile(data, *FilePath))
{
OnFail.Broadcast(0.f);
UE_LOG(LogTemp, Warning, TEXT("Unable to save file!"));
}
else
{
OnProgressUpdate.Broadcast(1.f);
UE_LOG(LogTemp, Warning, TEXT("File download completed!"));
}
}
OnFail.Broadcast(0.f);//FilePath
}