@ -149,7 +149,7 @@ Also, the substance of AC_File_SD (sd) is a FAT file of Arduino SD library porte
## When it will be uploaded
Upload handler will be launched by ESP8266WebServer/WebServer(ESP32) library which is triggered by receiving an HTTP stream of POST BODY including file content. Its launching occurs before invoking the page handler.
Upload handler will be launched by ESP8266WebServer/WebServer(as ESP32) library which is triggered by receiving an HTTP stream of POST BODY including file content. Its launching occurs before invoking the page handler.
The following diagram illustrates the file uploading sequence:
@ -180,17 +180,19 @@ AutoConnectUploadHandler()
#### <iclass="fa fa-caret-right"></i> Member functions
The **upload** public function is an entry point which will be invoked from the ESP8266WebServer (the WebServer for ESP32) library for each file content divided into chunks.
The **upload** public function is an entry point, the ESP8266WebServer (WebServer as ESP32) library will invoke the upload with each time of uploading content divided into chunks.
Also, the **\_open**, **\_write** and **\_close** protected functions are actually responsible for saving files and are declared as pure virtual functions. A custom uploader class that inherits from the AutoConnectUploadHandler class need to implement these functions.
The actual upload process is handled by the three private functions above, and then upload only invokes three functions according to the upload situation. In usually, there is no need to override the upload function in an inherited class.
```cpp
public virtual void upload(const String& requestUri, const HTTPUpload& upload)
```
<dlclass="apidl">
<dt>**Parameters**</dt>
<dd><spanclass="apidef">requestUri</span><spanclass="apidesc">URI of upload request source.</span></dd>
<dd><spanclass="apidef">upload</span><spanclass="apidesc">A data structure of the upload file as <b>HTTPUpload</b>. It is defined in the ESP8266WebServer (the WebServer for ESP32) library as follows:
<dd><spanclass="apidef">upload</span><spanclass="apidesc">A data structure of the upload file as <b>HTTPUpload</b>. It is defined in the ESP8266WebServer (WebServer as ESP32) library as follows:
```cpp
typedef struct {
@ -214,10 +216,11 @@ The upload handler needs to implement processing based on the enumeration value
- **`UPLOAD_FILE_END`** : Invokes to the \_close.
- **`UPLOAD_FILE_ABORTED`** : Invokes to the \_close.
The \_open function will be invoked when HTTPUploadStatus is **UPLOAD_FILE_START**. Usually, the implementation of an inherited class will open the file.
The \_open function will be invoked when HTTPUploadStatus is **UPLOAD_FILE_START**. Usually, the implementation of an inherited class will open the file.
@ -227,10 +230,11 @@ The \_open function will be invoked when HTTPUploadStatus is **UPLOAD_FILE_START
<dd><spanclass="apidef">false</span><spanclass="apidesc">Failed to open.</span></dd>
</dl>
The \_write function will be invoked when HTTPUploadStatus is **UPLOAD_FILE_WRITE**. The content of the upload file is divided and the \_write will be invoked in multiple times. Usually, the implementation of an inherited class will write data.
The \_write function will be invoked when HTTPUploadStatus is **UPLOAD_FILE_WRITE**. The content of the upload file is divided and the \_write will be invoked in multiple times. Usually, the implementation of an inherited class will write data.
@ -239,10 +243,11 @@ The \_write function will be invoked when HTTPUploadStatus is **UPLOAD_FILE_WRIT
<dd>Size written.</dd>
</dl>
The \_close function will be invoked when HTTPUploadStatus is **UPLOAD_FILE_END** or **UPLOAD_FILE_ABORTED**. Usually, the implementation of an inherited class will close the file.
```cpp
protected virtual void _close(void) = 0
```
The \_close function will be invoked when HTTPUploadStatus is **UPLOAD_FILE_END** or **UPLOAD_FILE_ABORTED**. Usually, the implementation of an inherited class will close the file.
For reference, the following AutoConnectUploadFS class is an implementation of AutoConnect built-in uploader and inherits from AutoConnectUploadHandler.
Registering the "not found" handler is a different way than ESP8266WebServer/WebServer. The *onNotFound* of ESP8266WebServer/WebServer does not work with AutoConnect. AutoConnect overrides *ESP8266WebServer::onNotFound*/*WebServer::onNotFound* to handle a captive portal. To register "not found" handler, use [*AutoConnect::onNotFound*](api.md#onnotfound).
Registering the "not found" handler is a different way than ESP8266WebServer (WebServer as ESP32). The *onNotFound* of ESP8266WebServer/WebServer does not work with AutoConnect. AutoConnect overrides *ESP8266WebServer::onNotFound*/*WebServer::onNotFound* to handle a captive portal. To register "not found" handler, use [*AutoConnect::onNotFound*](api.md#onnotfound).
### <iclass="fa fa-caret-right"></i> Access to saved credentials