Http put file example to create new/update file

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Http put file example to create new/update file

Postby snahmad75 » Fri Apr 20, 2018 7:32 am

How Can I use http put method to get file with its content and create this file on file system.

Example code works for Http get method.

static void helloWorldHandler(HttpRequest* pRequest, HttpResponse* pResponse)
{
printf("helloWorldHandler gets called\n");

pResponse->setStatus(HttpResponse::HTTP_STATUS_OK, "OK");
pResponse->addHeader(HttpRequest::HTTP_HEADER_CONTENT_TYPE, "text/plain");
pResponse->sendData("Hello back");
pResponse->close();
}

class HttpTask: public Task {
void run(void *data) {
ESP_LOGD("http", "Testing http ...");

HttpServer* pHttpServer = new HttpServer();
pHttpServer->addPathHandler(
HttpRequest::HTTP_METHOD_PUT,
"/helloWorld",
helloWorldHandler);
pHttpServer->start(80);


return;
}
};

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Http put file example to create new/update file

Postby WiFive » Fri Apr 20, 2018 8:29 am

https://github.com/nkolban/ESP32_Explorer

Spend some time searching GitHub

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: Http put file example to create new/update file

Postby snahmad75 » Fri Apr 20, 2018 8:52 am

Thanks. appreciated. I will try this code to upload file via Http.

Who is online

Users browsing this forum: No registered users and 124 guests