Resotre page transfer mode. Issue #51

pull/57/head
Hieromon Ikasamo 5 years ago
parent 4a4211df55
commit a2c1acc83a
  1. 3
      examples/FileUpload/FileUpload.ino
  2. 8
      mkdocs/achandling.md
  3. 2
      mkdocs/acjson.md
  4. 3
      src/AutoConnectDefs.h

@ -115,7 +115,8 @@ String postUpload(AutoConnectAux& aux, PageArgument& args) {
String content;
// Explicitly cast to the desired element to correctly extract
// the element using the operator [].
AutoConnectFile& filename = (AutoConnectFile&)auxUpload["filename"];
// AutoConnectAux& root_page = *portal.aux("/");
AutoConnectFile& filename = static_cast<AutoConnectFile&>(auxUpload["filename"]);
AutoConnectText& aux_filename = (AutoConnectText&)aux["filename"];
AutoConnectText& aux_size = (AutoConnectText&)aux["size"];
AutoConnectText& aux_contentType = (AutoConnectText&)aux["content_type"];

@ -101,6 +101,14 @@ AutoConenctText& text = aux->getElement<AutoConnectText>("caption"); // Cast to
Serial.println(text.value);
```
You can also use the operator **`[]`** as another way to get the desired element. An operator **`[]`** is a shortcut for [getElement](apiaux.me#getelement) function with the reference casting and makes simplify the code. Its argument is the name of the element to be acquired similarly to getElement function. For example, the following sketch code returns the same as reference of AutoConnectText element as `caption`.
```cpp
AutoConnectAux& aux = *portal.aux("/page1");
AutoConnectText& text1 = aux.getElement<AutoConnectElement>("caption");
AutoConnectText& text2 = (AutoConnectText&)aux["caption"];
```
To get all the AutoConnectElements in an AutoConnectAux object use the [**getElements**](apiaux.md#getelements) function. This function returns the vector of the reference wrapper as **AutoConnectElementVT** to all AutoConnectElements registered in the AutoConnectAux.
```cpp

@ -169,7 +169,7 @@ This is different for each AutoConnectElements, and the key that can be specifie
: - **style** : Specifies the qualification style to give to the content and can use the style attribute format as it is.
!!! caution "AutoConnect's JSON parsing process is not perfect"
It is based on ArduinoJson, but the process is simplified to save memory. As a result, even if there is an unnecessary key, it will not be an error. It is ignored.
It is based on analysis by ArduinoJson, but the semantic analysis is simplified to save memory. Consequently, it is not an error that a custom Web page JSON document to have unnecessary keys. It will be ignored.
## Loading JSON document

@ -119,8 +119,7 @@
// http response transfer method
#ifndef AUTOCONNECT_HTTP_TRANSFER
//#define AUTOCONNECT_HTTP_TRANSFER PB_ByteStream // Change for Issue #51
#define AUTOCONNECT_HTTP_TRANSFER PB_Chunk
#define AUTOCONNECT_HTTP_TRANSFER PB_ByteStream
#endif // !AUTOCONNECT_HTTP_TRANSFER
// Reserved buffer size to build content

Loading…
Cancel
Save