ESP32 Update.h problem

Hi all. I have try to make a process to update source by bin file to ESP32. So the source code to update file are in below.

void performOTAUpdate() {

  Serial.println("perform Start");

  
  // Create an HTTP client object
  HTTPClient http;

  Serial.println("Start request bin");

   // Begin the HTTP request
  http.begin(firmwareUrl);
//  http.setTimeout(1000*60*20);
  
  // Start the download and check for errors
  int httpCode = http.GET();

  Serial.println("End request ");

  drawOTAText("OTA : Request binary : request completed");

  Serial.print("Response request : " );
  Serial.println(httpCode);

  if (httpCode == HTTP_CODE_OK) {

 
    // Check the content length
    int contentLength = http.getSize();

    Serial.print("File content download : " );
    Serial.println(contentLength);

    if (contentLength > 0) {
      // Create a stream for the OTA update
      WiFiClient* stream = http.getStreamPtr();

      // Set the stream as the update source
      
      if (Update.begin(contentLength)) {
 
        uint8_t buffer[1024];
        int bytesRead = 0;

        Serial.println("Start patch rom");

       
        
        // Loop until all data is read
        if(http.connected()){
			int count=0;
          while ((bytesRead = stream->readBytes(buffer, sizeof(buffer))) > 0) {
              count++; 
			  
            if (Update.write(buffer, bytesRead) != bytesRead) {
              Serial.println("Error writing to firmware update");
   
              break;
            }
          }
 
        }

        
        if (Update.end()) {
          Serial.println("OTA update completed successfully");
 
          delay(delayReset);
          ESP.restart();

        } else {
          Serial.println("OTA update failed");
          Serial.println("OTA update failed. Reason: " + String(Update.getError()));
        

        }
      } else {
        Serial.println("OTA update could not begin");
        Serial.println("OTA update failed. Reason: " + String(Update.getError()));
        
      }
    } else {
      Serial.println("Invalid content length");
 
    }
  } else {
    Serial.print("Error downloading firmware: ");
    Serial.println(httpCode);

    
  }

  // Cleanup
  http.end();
}

As this above that my source code update. The problem from my software happen in Update.end(). At this function some got error 12 or 1. But I had check that already stream the bin file complete and memory or storage in esp32 still enough. For detail on this problem have anyone ever try and work with that please guide how to troubleshoot. Seem all of time to complete and success in update I had use my laptop in mobile hotspot mode. When I use router that not work. So I had try to write that bin file in spiffs memory that problem also same.

Thanks for suggestion.