@@ -345,13 +345,13 @@ void ESP8266WebServer::_parseArguments(String data) {
345
345
}
346
346
347
347
void ESP8266WebServer::_uploadWriteByte (uint8_t b){
348
- if (_currentUpload. currentSize == HTTP_UPLOAD_BUFLEN){
348
+ if (_currentUpload-> currentSize == HTTP_UPLOAD_BUFLEN){
349
349
if (_currentHandler && _currentHandler->canUpload (_currentUri))
350
- _currentHandler->upload (*this , _currentUri, _currentUpload);
351
- _currentUpload. totalSize += _currentUpload. currentSize ;
352
- _currentUpload. currentSize = 0 ;
350
+ _currentHandler->upload (*this , _currentUri, * _currentUpload);
351
+ _currentUpload-> totalSize += _currentUpload-> currentSize ;
352
+ _currentUpload-> currentSize = 0 ;
353
353
}
354
- _currentUpload. buf [_currentUpload. currentSize ++] = b;
354
+ _currentUpload-> buf [_currentUpload-> currentSize ++] = b;
355
355
}
356
356
357
357
uint8_t ESP8266WebServer::_uploadReadByte (WiFiClient& client){
@@ -453,21 +453,22 @@ bool ESP8266WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t
453
453
break ;
454
454
}
455
455
} else {
456
- _currentUpload.status = UPLOAD_FILE_START;
457
- _currentUpload.name = argName;
458
- _currentUpload.filename = argFilename;
459
- _currentUpload.type = argType;
460
- _currentUpload.totalSize = 0 ;
461
- _currentUpload.currentSize = 0 ;
456
+ _currentUpload.reset (new HTTPUpload ());
457
+ _currentUpload->status = UPLOAD_FILE_START;
458
+ _currentUpload->name = argName;
459
+ _currentUpload->filename = argFilename;
460
+ _currentUpload->type = argType;
461
+ _currentUpload->totalSize = 0 ;
462
+ _currentUpload->currentSize = 0 ;
462
463
#ifdef DEBUG_ESP_HTTP_SERVER
463
464
DEBUG_OUTPUT.print (" Start File: " );
464
- DEBUG_OUTPUT.print (_currentUpload. filename );
465
+ DEBUG_OUTPUT.print (_currentUpload-> filename );
465
466
DEBUG_OUTPUT.print (" Type: " );
466
- DEBUG_OUTPUT.println (_currentUpload. type );
467
+ DEBUG_OUTPUT.println (_currentUpload-> type );
467
468
#endif
468
469
if (_currentHandler && _currentHandler->canUpload (_currentUri))
469
- _currentHandler->upload (*this , _currentUri, _currentUpload);
470
- _currentUpload. status = UPLOAD_FILE_WRITE;
470
+ _currentHandler->upload (*this , _currentUri, * _currentUpload);
471
+ _currentUpload-> status = UPLOAD_FILE_WRITE;
471
472
uint8_t argByte = _uploadReadByte (client);
472
473
readfile:
473
474
while (argByte != 0x0D ){
@@ -503,18 +504,18 @@ bool ESP8266WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t
503
504
504
505
if (strstr ((const char *)endBuf, boundary.c_str ()) != NULL ){
505
506
if (_currentHandler && _currentHandler->canUpload (_currentUri))
506
- _currentHandler->upload (*this , _currentUri, _currentUpload);
507
- _currentUpload. totalSize += _currentUpload. currentSize ;
508
- _currentUpload. status = UPLOAD_FILE_END;
507
+ _currentHandler->upload (*this , _currentUri, * _currentUpload);
508
+ _currentUpload-> totalSize += _currentUpload-> currentSize ;
509
+ _currentUpload-> status = UPLOAD_FILE_END;
509
510
if (_currentHandler && _currentHandler->canUpload (_currentUri))
510
- _currentHandler->upload (*this , _currentUri, _currentUpload);
511
+ _currentHandler->upload (*this , _currentUri, * _currentUpload);
511
512
#ifdef DEBUG_ESP_HTTP_SERVER
512
513
DEBUG_OUTPUT.print (" End File: " );
513
- DEBUG_OUTPUT.print (_currentUpload. filename );
514
+ DEBUG_OUTPUT.print (_currentUpload-> filename );
514
515
DEBUG_OUTPUT.print (" Type: " );
515
- DEBUG_OUTPUT.print (_currentUpload. type );
516
+ DEBUG_OUTPUT.print (_currentUpload-> type );
516
517
DEBUG_OUTPUT.print (" Size: " );
517
- DEBUG_OUTPUT.println (_currentUpload. totalSize );
518
+ DEBUG_OUTPUT.println (_currentUpload-> totalSize );
518
519
#endif
519
520
line = client.readStringUntil (0x0D );
520
521
client.readStringUntil (0x0A );
@@ -604,8 +605,8 @@ String ESP8266WebServer::urlDecode(const String& text)
604
605
}
605
606
606
607
bool ESP8266WebServer::_parseFormUploadAborted (){
607
- _currentUpload. status = UPLOAD_FILE_ABORTED;
608
+ _currentUpload-> status = UPLOAD_FILE_ABORTED;
608
609
if (_currentHandler && _currentHandler->canUpload (_currentUri))
609
- _currentHandler->upload (*this , _currentUri, _currentUpload);
610
+ _currentHandler->upload (*this , _currentUri, * _currentUpload);
610
611
return false ;
611
612
}
0 commit comments