Upload files to a Livechat room.
HTTP Method | URL | Requires Auth |
---|---|---|
POST | /api/v1/livechat/upload/:rid | yes (with visitor token) |
Key | Example Value | Description |
---|---|---|
x-visitor-token * | iNKE8a6k6cjyPyOyI | The visitor token. |
Key | Example Value | Description |
---|---|---|
rid * | HkHAXmXTdvZigri2X | The room ID. |
Key | Example Value | Description |
---|---|---|
file * | image-file.jpg | The file to be uploaded. |
description | image description | The file description. |
{% code overflow="wrap" %}
curl --location --request POST 'http://localhost:3000/api/v1/livechat/upload/HkHAXmXTdvZigri2X' \
--header 'x-visitor-token: iNKE8a6k6cjyyyyyy' \
--form 'file=@"/home/rodriq/Desktop/cod.png"' \
--form 'description="image file description here"'
{% endcode %}
{
"_id": "CeswhhAKTQMsnEbc8",
"rid": "cbjQCtywHbuTYzmLx",
"msg": "",
"token": "932a1c3019aeeaa9b687bb04b979d",
"file": {
"_id": "uredcLri4GdehDQnD",
"name": "globe.png",
"type": "image/png"
},
"attachments": [
{
"ts": "1970-01-01T00:00:00.000Z",
"title": "globe.png",
"title_link": "/file-upload/uredcLri4GdehDQnD/globe.png",
"title_link_download": true,
"image_dimensions": {
"width": 1746,
"height": 1624
},
"image_preview": "/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAeACADASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAABwgBBQYJ/8QAKhAAAQIFAgQHAQEAAAAAAAAAAQIDAAQFBgcREgghIjETFCNCUVJhQXH/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AF2DMUu33PmbnypqkMq61fc/AhzrStCjWvLNsUWRbl0pGhWO5ikwtQGaRjykMNJCQpreoj3GCA5o20efIdoDJ3rZ1vXXKOMVeRbeWoaBz3D/ISzNWMJiwaqHGCp2lPn0nPr+GHvO1XPuYHHEFRWqpjKqF9A3y6fEQo/wwE8P11s3JjaRQ26PNyQ8N1GvMQVmwHmBvHeOcON79qtiVlM7S3CWlcnWSelYh4cT5HZvumoeRIuSrgT1aqBGv5AbTw9sxtAJSIEnFJdUtRMevyAWnzk90JRrz0+Yvcu5QasGSWsU9czMKHSdwCQf2EhyBetVviuOVGrulRJ9NsHpQPgQH/9k=",
"image_url": "/file-upload/uredcLri4GdehDQnD/globe.png",
"image_type": "image/png",
"image_size": 562975,
"type": "file",
"description": "Here is the file",
"descriptionMd": [
{
"type": "PARAGRAPH",
"value": [
{
"type": "PLAIN_TEXT",
"value": "Here is the file"
}
]
}
]
}
],
"alias": "James",
"ts": "2023-03-21T16:21:39.131Z",
"u": {
"_id": "6410766605957d866e0fcf37",
"username": "guest-3",
"name": "James"
},
"_updatedAt": "2023-03-21T16:21:39.173Z",
"urls": [],
"mentions": [],
"channels": [],
"newRoom": false,
"showConnecting": false,
"success": true
}
Any of the following errors can occur:
- Authorization: Requires an authentication token for the request to be made.
- File type error: Occurs when the file to be uploaded is of a type that has been blocked in the upload settings.
- File size error: This happens when the file to be uploaded is larger than the maximum file size set in the upload settings.
- Invalid file: This is seen when the upload fails for some reason.
{% tabs %} {% tab title="Authorization" %}
{
"success": false,
"error": "unauthorized"
}
{% endtab %}
{% tab title="File Type" %}
{
"reason": "error-type-not-allowed",
"success": false
}
{% endtab %}
{% tab title="File Size" %}
{
"reason": "error-size-not-allowed",
"success": false
}
{% endtab %}
{% tab title="Invalid File" %}
{
"reason": "Invalid file",
"success": false
}
{% endtab %} {% endtabs %}