Skip to content

Files could neither be deleted nor downloaded - example 2 #4

@janphoffmann

Description

@janphoffmann

In the example 2 I could not download the uploaded file and could not delete the uploaded file.

I traced the issue to: line 99: if(!SPIFFS.exists(filename)
the filename is defined with: const char *fileName = request->getParam("name")->value().c_str(); (line 94)

I did a rather ugly workauround with the following code:

    char *cstr1 = (char*)malloc(strlen(request->getParam("name")->value().c_str())+1);
    strcpy(cstr1,"/");
    strcat(cstr1, fileName);
    if (!SPIFFS.exists(cstr1)){
    .
    .
     request->send(SPIFFS, cstr1, "application/octet-stream");
     .
    .
    SPIFFS.remove(cstr1);
    .
    .
    free(cstr1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions