title: How can SPIFFS file be downloaded using AsyncWebServer?
body: <p>Below Arduino ESP32 code creates a list of files as URL's.  I am converting WiFi client/server project to use the AsyncWebServer library.  Need help extracting file name from URL and be able to detect filename to download in Async Web Server.  </p>
  
  <pre><code>String str;
  
  if (!SPIFFS.begin(true))
  {
       Serial.println("An Error has occurred while mounting SPIFFS");
       return;
  }
  
  File root = SPIFFS.open("/");
  
  File file = root.openNextFile();
  
  while (file)
  {
  
       if(strncmp(file.name(), "/LOG", 4) == 0)
       {
            str += "&lt;a href=\"";
            str += file.name();
            str += "\"&gt;";
            str += file.name();
            str += "&lt;/a&gt;";
            str += "    ";
            str += file.size();
            str += "&lt;br&gt;\r\n";
  
       }
  
       file = root.openNextFile();
  }
  
  client.print(str);
  </code></pre>
  
  <p>Attempt to code for Asyncwebserver:</p>
  
  <pre><code>serverAsync.on(filename, HTTP_GET, [](AsyncWebServerRequest *request){
  AsyncWebServerResponse *response = request-&gt;beginResponse(200, "text/plain", "Ok");
  response-&gt;addHeader("Content-Disposition", "attachment");
  request-&gt;send(response);
  });
  </code></pre>
  
  <p>This code produces:  Download window with correct filename; however, content is only "ok."</p>
  
  <p>My initial attempt was to try something with PHP.  I am less than an experienced coder with PHP and with Async Web Server.</p>
  
  <p>William</p>