Sound files for playback while holding down (waitonholdcustom)

Overview

Provides access to files used for playback in phone calls to a held subscriber. The application of the files is independent of the domain to which the caller accounts belong.

The composition of the files is arbitrary. Initially, the files fall into the directory from assets. When placed on hold, a random file from the directory (or, if the directory is empty, from the storage) is played back waitonhold).

The directory is located in the category of automatically synchronized directories :SYNC.

The catalog is accessed from scripts using the catalog category prefix ":SYNC_COMMON/wait/hold".

Requests

HTTP verb Endpoint Description

POST

/rest/v1/fs/targets/waitonholdcustom

Pouring a group of files

GET

/rest/v1/fs/targets/waitonholdcustom

Getting a list of files

GET

/rest/v1/fs/targets/waitonholdcustom/<filename>

File download

PUT

/rest/v1/fs/targets/waitonholdcustom/<filename>

Reloading an existing file

DELETE

/rest/v1/fs/targets/waitonholdcustom/<filename>

Deleting a file

HEAD

/rest/v1/fs/targets/waitonholdcustom/<filename>

Getting meta-information about a file


Pouring a group of files

Uploading to the collection is done by Content-Type: multipart/formdata.

There can be one or more files in the request. The files are placed under the names specified in the Content-Disposition headers of each part.

If a file with the specified name already exists, it is not saved and returns an error. Depending on the Content-Type and the presence of successfully placed files, the request may return a failed HTTP response, or failure information in the body of the HTTP response 200 OK.

Request

Request example
POST /rest/v1/fs/targets/waitonholdcustom HTTP/1.1
Content-Type: multipart/form-data; boundary=-----------boundary_69df8120352a996e

-----------boundary_69df8120352a996e
Content-Type: application/octet-stream
Content-Disposition: form-data; name="filename"; filename="hold_music.wav"
Content-Transfer-Encoding: binary

BINARY BODY OF 'hold_music.wav'
-----------boundary_69df8120352a996e--

Response

Response example
[
  {
    "name": "01.mp3",
    "size": 70985,
    "status": "ok"
  },
  {
    "name": "hold_music.wav",
    "size": 1596292,
    "status": "ok"
  }
]

Getting a list of files

Request

Table 1. Request parameters
Name Type Description

filter

object

Filter by field values.

mask

str

List of fields to output. Available fields for output: name, size, last_modified.

offset

int

Offset in the list of files to be issued.

limit

int

Maximum number of files in the list.

order

array<object|str>

The sort order of the files in the list.

Request example
GET /rest/v1/fs/targets/waitonholdcustom HTTP/1.1

Response

Response example
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[
  {
    "name": "F.zip",
    "size": 8411,
    "last_modified": "2019-09-20 10:30:43"
  },
  {
    "name": "Package.bin",
    "size": 12268,
    "last_modified": "2019-09-20 10:30:43"
  }
]

File download

Request

Table 2. Request parameters
Name Type Description

attachment

bool

Issuance Type. Default false.

true – is output with the header Content-Disposition: attachment; filename=filename.ext or Content-Disposition: attachment; filename*=UTF-8''%d1%84%d0%b0%d0%b9%d0%bb.ext, where file.ext is the file name in UTF-8 encoding and URLencoded.

false – untitled Content-Disposition.

Request example
GET /rest/v1/fs/targets/waitonholdcustom/hold_music.wav?attachment=true HTTP/1.1

Response

Response example
HTTP/1.1 200 OK
Content-Type: application/octet-stream; charset=utf-8
Content-Disposition: attachment; filename*=UTF-8''hold_music.wav

BINARY BODY OF 'hold_music.wav'

Reloading an existing file

Performs a file replacement.

A single file is uploaded either with Content-Type: multipart/formdata, or with an arbitrary Content-Type that is not multipart.

If the download is done with Content-Type: multipart/formdata, then only the first file will be saved (the first part with the filename field in the header) Content-Disposition), and the file name itself will be ignored.

Request

Request example (octet-stream)
PUT /rest/v1/fs/targets/waitonholdcustom/hold_music.wav HTTP/1.1
Content-Type: application/octet-stream

BINARY BODY OF 'hold_music.wav'
Request example (multipart)
PUT /rest/v1/fs/targets/waitonholdcustom/hold_music.wav HTTP/1.1
Content-Type: multipart/form-data; boundary=-----------boundary_69df8120352a996e

-----------boundary_69df8120352a996e
Content-Type: application/octet-stream
Content-Disposition: form-data; name="hold_music.wav"; filename="hold_music.wav"
Content-Transfer-Encoding: binary

BINARY BODY OF 'hold_music.wav'
-----------boundary_69df8120352a996e--

Response

Response example
HTTP/1.1 204 No Content

Deleting a file

Request

Request example
DELETE /rest/v1/fs/targets/waitonholdcustom/hold_music.wav HTTP/1.1

Response

Response example
HTTP/1.1 204 No Content

Getting meta-information about a file

Returns meta-information about the file, including the size in the header Content-Length.

Features

  • HTTP-the response does not contain a body, despite the presence of a header Content-Length.

Request

Table 3. Request parameters
Name Type Description

attachment

bool

Issuance Type. Default false.

true – is output with the header Content-Disposition: attachment; filename=filename.ext or Content-Disposition: attachment; filename*=UTF-8''%d1%84%d0%b0%d0%b9%d0%bb.ext, where file.ext is the file name in UTF-8 encoding and URLencoded.

false – untitled Content-Disposition.

Request example
HEAD /rest/v1/fs/targets/waitonholdcustom/hold_music.wav?attachment=true HTTP/1.1

Response

Example of a successful response
HTTP/1.1 200 OK
content-type: audio/x-wav
last-modified: Fri, 20 Sep 2019 09:26:44 GMT
content-disposition: attachment; filename=hold_music.wav
content-length: 1596292
Example of an unsuccessful response
HTTP/1.1 404 Not Found

See also