View Single Post
BlackFart
Junior Member
Join Date: Feb 2021
Old 02-14-2021 , 15:34   Re: REST in Pawn 1.2 - HTTP client for JSON REST APIs (Updated 2021/02/07)
Reply With Quote #89

Hello,
This is the only extension I found for uploading files through http (demos recorded).
It doesn't seem like to work for me... (I found cURL, but it's not working for me either... )

Here is what I'm doing, calling CheckOldDemos() in OnMapStart()
Code:
HTTPClient httpClient;

public void CheckOldDemos()
{
    DirectoryListing  dl = OpenDirectory(newDemoPath);
    char newDemo[256];
    while(dl.GetNext(newDemo, sizeof(newDemo))) {
        if(SimpleRegexMatch(newDemo, ".*dem$") <= 0) {
            continue;
        }
        httpClient = new HTTPClient("localhost:8080/url");

        char demoPath[PLATFORM_MAX_PATH];
        BuildPath(Path_SM, demoPath, sizeof(demoPath), "data/image.jpg"); 

        httpClient.UploadFile("upload", demoPath, OnDemoUploaded); 
    }
}

void OnDemoUploaded(HTTPStatus status, any value)
{
    if (status != HTTPStatus_OK) {
        PrintToServer("Noooooooooooooo %d", status);
        return;
    }

    PrintToServer("Upload complete");
}
Nothing is printed from OnDemoUploaded(), the programm go through httpClient.UploadFile() without any error from what I can see, and I got nothing on my API

Thank for your help

EDIT: ok, after some tests, no example works... and I get no errors in the console I also tried with older version, so the issue isn't your last update 7 days ago... I really don't understand, even your example with a get doesn't work (it prints nothing)

Last edited by BlackFart; 02-14-2021 at 16:47.
BlackFart is offline