Apologies for the slow response, I'll get someone to take a closer look at this for you.
Thanks,
Liam
D
Dann Rees
said
over 6 years ago
No Problem! It started working eventually?!. The code is below in case somebody needs it. However, when I was getting errors (the "Unable to upload image" message), it was still returning a 200 OK response. Would it be possible for you to change that to an error code response (500?) so I can easily check for it.
Thanks!
Http = &FHttpModule::Get();
if (Http && Http->IsHttpEnabled())
{
TSharedRef < IHttpRequest > Request = Http->CreateRequest();
FString TexturePath = FPaths::GameSavedDir() + "\\Landscape.png";
// get data
TArray<uint8> UpFileRawData;
FFileHelper::LoadFileToArray(UpFileRawData, *TexturePath);
Request->SetURL(URL);
Request->SetVerb("POST");
Request->SetHeader("Content-Type", "multipart/form-data; boundary=blahblahsomeboundary");
FString a = "\r\n--blahblahsomeboundary\r\n";
FString b = "Content-Disposition: form-data; name=\"file\"; filename=\"landscape2.png\"\r\n";
FString c = "Content-Type: image/png\r\n\r\n";
//d = UpFileRawData
FString e = "\r\n--blahblahsomeboundary--\r\n";
TArray<uint8> data;
data.Append((uint8*)TCHAR_TO_UTF8(*a), a.Len());
data.Append((uint8*)TCHAR_TO_UTF8(*b), b.Len());
data.Append((uint8*)TCHAR_TO_UTF8(*c), c.Len());
data.Append(UpFileRawData);
data.Append((uint8*)TCHAR_TO_UTF8(*e), e.Len());
Request->SetContent(data);
Request->OnProcessRequestComplete().BindUObject(this, &UFileUploader::OnResponseReceived);
if (!Request->ProcessRequest())
{
OnFailure.Broadcast();
}
}
else OnFailure.Broadcast();
Dann Rees
Hi there,
I'm trying to figure out how to upload binary files from UE4 (C++).
I'm getting the URL with GetUploadURLRequest then passing it on to the function below. But I just get a connection lost message.
Thanks
Just to add to this. I've tried the code below. I get a 200 response but an "Unable to upload file" message?
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstDann Rees
Just to add to this. I've tried the code below. I get a 200 response but an "Unable to upload file" message?
Customer Support
Hi Dan,
Apologies for the slow response, I'll get someone to take a closer look at this for you.
Thanks,
Liam
Dann Rees
No Problem! It started working eventually?!. The code is below in case somebody needs it. However, when I was getting errors (the "Unable to upload image" message), it was still returning a 200 OK response. Would it be possible for you to change that to an error code response (500?) so I can easily check for it.
Thanks!
1 person likes this
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics