-->
Page 1 of 2

Increase Upload Speed

PostPosted: Mon Dec 17, 2018 11:25 am
by Nitek
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?

Re: Increase Upload Speed

PostPosted: Tue Dec 18, 2018 8:48 am
by rudy
Is the upload speed the problem or the write to SD?

Re: Increase Upload Speed

PostPosted: Tue Dec 18, 2018 2:51 pm
by Nitek
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)

Re: Increase Upload Speed

PostPosted: Wed Dec 19, 2018 1:50 pm
by rudy