Sending OTA over RS485 from one ESP to another

I have question currently have this idea, but don't know if its the right one.
So what I want is to send binary file from one ESP to another via RS485.

What I think would be the best, download .bin from URL via client, save it to SPIFF and after save is done, start sending data from file to another ESP. Here I have first problem, currently I'm just playing with some .txt file, which I download from URL, but file is not saved completely at last bigger files are not. For example file which is about 200kb has been saved, bigger files are not saved at all. Already in start I get from client for example 3/4 data of complete file soo for example 1/4 is already missing.

Here is my code with which I start. Currently I'm just saving data to SD card, next will be SPIFF.

void getFile() {
  WiFiClient client;
  const char http_site[] = "xyz";
  const int http_port = 80;

  if (client.connect(http_site, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    Serial.println("##########################");
    Serial.println("");
    client.println("GET /test.txt HTTP/1.1"); //download text
    client.println("Host: xyz");
    client.println("Connection: close");  //close 1.1 persistent connection
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  String readString;
  String readChar;
  while (client.connected() && !client.available()) delay(1); //waits for data

  File fileWrite;

  fileWrite = SD.open("/test.txt", FILE_WRITE);
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read();
    readString += c;

    readChar = c;

    String content = readChar;
    //fileWrite.println(content);

    fileWrite.print(content);

  }

  fileWrite.close();

  int index = readString.indexOf("Accept-Ranges: bytes");
  readString.remove(0, index + 20);
  readString.trim();

  client.stop(); //stop client

  Serial.println("##########################");
  if (readString.length() > 0) {
    Serial.println("Receive from client:");
    Serial.println("Size: " + String(readString.length()));
    // Serial.println(readString);
    // I2CExpander.write(SC16IS752_CHANNEL_A, readString);

    Serial.println(readString);

    // fileWrite("/test.txt", readString);
    // fileOpen("/test2.bin");
  }
  Serial.println("##########################");


  readString = ""; //clear readString variable
}

use the Updater object from core

Which precisely?

I have time. you have to be proactive and use the clue if you want to solve your problem. which esp? didn't you find the Updater?

Its ESP32 on both sites.

esp32 arduino has Update library bundled. it has examples

I have problem here for this code:

After runing this code, size of file always is 0, file size is about 4mb, if I lower data from client file for example if file is like 100kb of size, than content is written in file on my SD card. SD card is 8gb size so there is enough space. What is wrong in this case?

int contentLength = -1;
  int httpCode;

  while (client.connected())
  {
    String header = client.readStringUntil('\n');
    if (header.startsWith(F("HTTP/1.")))
    {
      httpCode = header.substring(9, 12).toInt();
      if (httpCode != 200)
      {
        client.stop();
      }
    }
    if (header.startsWith(F("Content-Length: ")))
    {
      contentLength = header.substring(15).toInt();
    }
    if (header == F("\r"))
    {
      break;
    }
  }

  if (!(contentLength > 0))
  {
    client.stop();
  }

  // Download file
  int remaining = contentLength;
  int received;
  uint8_t buff[512] = { 0 };

  // read all data from server
  File fileWrite;

  fileWrite = SD.open("/test.txt", FILE_WRITE);

  Serial.println();
  Serial.println(fileWrite.size()); // here return about 4mb
  Serial.println();

  while (client.available() && remaining > 0)
  {
    // read up to buffer size
    received = client.readBytes(buff, ((remaining > sizeof(buff)) ? sizeof(buff) : remaining));

    // write it to file
    // f.write(buff, received);
    fileWrite.write(buff, received);

    if (remaining > 0)
    {
      remaining -= received;
    }
    yield();
  }

  Serial.println();
  Serial.println(fileWrite.size()); // here always return 0
  Serial.println();

  fileWrite.close();

  if (remaining != 0) {

  }

  Serial.println("end");```