Prohlížíte starou verzi této stránky. Zobrazit aktuální verzi.

Porovnat s aktuální Zobrazit historii stránky

« Předchozí Verze 3 Aktuální »

To upload a file.

Request

  • Urn:             /api/upload
  • Method:      POST
  • Request header:  Cookie: session  - actual session value.
  • Request type:       multipart/form-data
  • Request content: Multipart items (1. item: name="json" + 2. item: name="file")

    Caution

    • It‘s necessary to keep the order of these items.
    1. name="json": A string item with the json structure.

      Json schema
      {
            "$schema": "http://json-schema.org/draft-07/schema#",
            "title": "upload - request",
            "type": "object",
            "properties": {
                 "name": {
                     "type": "string"
                 }
            },
            "required": [
                 "name"
            ],
            "additionalProperties": false
      }
    2. name="file": Binary/text file data to send.
  • Meaning of json items:
    • Json string with the following content:
      • $.name:
        File type content definition; defined by parameter name.
        Type: string.
        Mandatory

      • file:
        File content to upload

Json multipart item example
{
	"name": "config"
}
Http request example
POST /api/upload HTTP/1.1
    Content-Type: multipart/form-data; boundary=----BoundaryIdentificatorkTrZ
    Content-Length: 205
    Cookie: session=f3a78dd4e51e7
    ------BoundaryIdentificatorkTrZu0gW
    Content-Disposition: form-data; name="json"

    {"name":"firmware"}
    ------BoundaryIdentificatorkTrZu0gW
    Content-Disposition: form-data; name="file" filename="fw.bin"
    Content-Type: application/octet-stream

    (… binary file data …)
    ------BoundaryIdentificatorkTrZ--

Response

  • Response code:
    • 200 – OK
    • 400 – Error (bad request)
    • 401 – Unauthorized
    • 500 – Server error
    • 512 - Internal application error
  • Response header: Set-Cookie: session  - Actual session value.
  • Response type: json
Json schema:
{
      "$schema": "http://json-schema.org/draft-07/schema#",
      "title": "upload - response",
      "type": "object",
      "properties": {
        "status": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "minLength": 1,
            "pattern": "^[a-z_][a-z0-9_]*$"
          }
        }
      },
      "additionalProperties": false
}

Meaning of json items:

  • $.status:
    List of unsaved parameter values.
    Is present only for response with response code 400 – Bad request. There can be only one item in the status object.
    Type: object
    Optional.
    • Format of list items: "<parameter_name>": "<error_status>"
      <parameter_name> – name of reported parameter
      <error_status> – type of error.
    • Possible values:
      "undefined" – parameter not exists
      "bad value" – parameter value is out of range
      "bad type" – wrong type of parameter value
      "access denied" – parameter is not accessible for write
      "no memory" – not enough memory
      "error" – general internal error
      "busy" – device is in busy state (e.g. during the factory init process or upgrade process)
Example
{
      "status": {
        "cfg_update ": "busy"
      }
}
  • Žádné štítky