How do I solve the problem of a small buffer size when reading files and saving?

 while (file.available()) {
      uint8_t buffer[4096];
      int bytesRead = file.read(buffer, 4096);
      client.write(buffer, bytesRead);
    }

An error occurs with a large buffer. Are there other ways? I need a speed of at least 1 Mbyte/s? Other libraries? ESP32 - 4MB.

Welcome to the forum

Make the buffer smaller and read the data into it and out of it in smaller chunks until all of the data has been read and written ?

is that an SD based file or reading from flash ?
what's the client? just a WiFiClient instance ?

the GitHub - me-no-dev/AsyncTCP: Async TCP Library for ESP32 is faster than WiFiClient but not a drop in replacement

may be check also fast WiFi file download · Issue #4529 · espressif/arduino-esp32 · GitHub

I have a file: conditionally weighs 500 kilobytes. But does this procedure take 2 minutes? This is not normal. Do I need it in a split second

SPIFFS Internal storage. Yes right. It turns out that the wi-fi speed is limited by the time for these two operations. 500 kilobytes 2 minutes transmits. It's very slow

yeah great performance is not guaranteed...

sometimes smaller buffer has better performance. the flash can write data sent while wifi receives the next packet

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.