Chat freely about anything...

User avatar
By Nitek
#79605 Hi there,

I created a web interface which allows me to upload files onto a (SPI connected) SD card. Everything works ok, but the upload speed is only around 100kb/s. Is there any chance to speed this up? My upload code is pretty basic:

Code: Select allESP8266WebServer server(80);
server.on("/", HTTP_POST, handleNotFound, handleFileUpload);

void handleFileUpload() {
  // Upload always happens on /
  if (server.uri() != "/") {
    Serial.println(F("Invalid upload URI"));
    return;
  }

  HTTPUpload& upload = server.upload();

  if (upload.status == UPLOAD_FILE_START) {
    String filename = upload.filename;
    uploadFile.open((char *)filename.c_str(), FILE_WRITE);
    uploadStart = millis();
    Serial.print(F("UPLOAD_FILE_START: "));
    Serial.println(filename);
  } else if (upload.status == UPLOAD_FILE_WRITE) {
    if (uploadFile.isOpen()) {
      uploadFile.write(upload.buf, upload.currentSize);
      Serial.print(F("UPLOAD_FILE_WRITE: "));
      Serial.println(upload.currentSize);
    }
  } else if (upload.status == UPLOAD_FILE_END) {
    if (uploadFile.isOpen()) {
      uploadFile.close();
      Serial.print(F("UPLOAD_FILE_END: "));
      Serial.println(upload.totalSize);
      Serial.print(F("Took: "));
      Serial.println(((millis()-uploadStart)/1000));
    }
  }
}


(Reducing the Serial output did not affect the upload speed).
Any ideas/tips?
User avatar
By Nitek
#79619 Good question - Hadn't ruled out the SD yet. If remove the uploadFile.write line, upload speed goes up to 130kb/s so I don't think the SD card is the issue here (also it might offer small room for improvement)