# WsContents

## Overview

The `WsContents` class represents the contents or parts of an HTTP request. It provides functionality to access metadata and content details of uploaded files or form data in a request. The contents include attributes such as the content name, field name, content type, size, and raw byte data. Additionally, it allows retrieval of the content as a string with a specified encoding.

Key methods include `getName()` to get the content name, `getFieldName()` to retrieve the field name, `getContentType()` to access the MIME type, and `getSize()` to get the content size in bytes. The class also provides methods like `getBytes()` to obtain raw byte data and `getString(encoding)` to convert the content into a string using a specified encoding.

## Properties Summarized

| Type                                                | Name                        | Summary                    |
| --------------------------------------------------- | --------------------------- | -------------------------- |
| [Array](../../../servoycore/dev-api/js-lib/array)   | [bytes](#bytes)             | Get contents bytes.        |
| [String](../../../servoycore/dev-api/js-lib/string) | [contentType](#contenttype) | Get contents content type. |
| [String](../../../servoycore/dev-api/js-lib/string) | [fieldName](#fieldname)     | Get contents field name.   |
| [String](../../../servoycore/dev-api/js-lib/string) | [name](#name)               | Get contents name.         |
| [Number](../../../servoycore/dev-api/js-lib/number) | [size](#size)               | Get contents size.         |
| [String](../../../servoycore/dev-api/js-lib/string) | [string](#string)           | Get contents as string.    |

## Properties Detailed

### bytes

Get contents bytes.

**Type**\
[Array](../../../servoycore/dev-api/js-lib/array)

**Sample**

```js
var request = plugins.rest_ws.getRequest();
var contents = request.getContents();
if (contents.length > 0) {
   var bytes = contents[0].getBytes();
}
```

### contentType

Get contents content type.

**Type**\
[String](../../../servoycore/dev-api/js-lib/string)

**Sample**

```js
var request = plugins.rest_ws.getRequest();
var contents = request.getContents();
if (contents.length > 0) {
   var contentType = contents[0].getContentType();
}
```

### fieldName

Get contents field name.

**Type**\
[String](../../../servoycore/dev-api/js-lib/string)

**Sample**

```js
var request = plugins.rest_ws.getRequest();
var contents = request.getContents();
if (contents.length > 0) {
   var fieldName = contents[0].getFieldName();
}
```

### name

Get contents name.

**Type**\
[String](../../../servoycore/dev-api/js-lib/string)

**Sample**

```js
var request = plugins.rest_ws.getRequest();
var contents = request.getContents();
if (contents.length > 0) {
   var name = contents[0].getName();
}
```

### size

Get contents size.

**Type**\
[Number](../../../servoycore/dev-api/js-lib/number)

**Sample**

```js
var request = plugins.rest_ws.getRequest();
var contents = request.getContents();
if (contents.length > 0) {
   var size = contents[0].getSize();
}
```

### string

Get contents as string.

**Type**\
[String](../../../servoycore/dev-api/js-lib/string)

**Sample**

```js
var request = plugins.rest_ws.getRequest();
var contents = request.getContents();
if (contents.length > 0) {
   var string = contents[0].getString('UTF-8');
}
```

***
