Skip to content

Uploading a zero byte file does not fire any write event #292

@Gerporgl

Description

@Gerporgl

Platform

ESP32

IDE / Tooling

pioarduino

What happened?

When doing a request handling such as _webserver->on("/files", HTTP_ANY, handleFileRequest, handleFileUpload), and sending a zero byte file, the handleFileUpload never gets called.

I would have expected to receive a handler call for handleFileUpload with final==true, index==0, len==0, etc.

This seems a bit awkward to do in the request handler afterward, because of the multipart upload, you can't only check the content-length, and also need to get the filename, etc.
At least if the handleFileUpload was sending a zero len/final event this would allow for a more generic and straightforward file writing implementation.

Stack Trace

There is no stack trace in this case

Minimal Reproductible Example (MRE)

Need to upload a zero byte file from a browser page designed for this, or I guess you can do it with curl as well, then implement the handler like this:

_webserver->on("/fileupload", HTTP_ANY, handleFileRequest, handleFileUpload);

 void handleFileUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
       // This never get called
}

void handleFileRequest(AsyncWebServerRequest *request) {
        // This gets called
}

I confirm that:

  • I have read the documentation.
  • I have searched for similar discussions.
  • I have searched for similar issues.
  • I have looked at the examples.
  • I have upgraded to the lasted version of ESPAsyncWebServer (and AsyncTCP for ESP32).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions