Post a message with the attached file to a dedicated room.
HTTP Method | URL | Requires Auth |
---|---|---|
POST | /api/v1/rooms.upload/:rid | yes |
Key | Example Value | Description |
---|---|---|
rid * | hdsjjd783hkd | The room ID to which you want to upload the file. |
Key | Example Value | Description |
---|---|---|
file * | $HOME/example.txt | A file name to upload. |
msg | This is a message with a file | A message text. |
description | Simple text file | A description of the file. |
tmid | vg3h21v31v23 | The thread message id (if you want upload a file to a thread). |
customFields | {"priority": "high"} | You can add custom fields for messages. For example, set priorities for messages. You must enable this option and define the validation in the workspace settings. See the Message settings for further information. |
curl "http://localhost:3000/api/v1/rooms.upload/GENERAL" \
-F file=@$HOME/example.txt \
-F "msg=This is a message with a file" \
-F "description=Simple text file" \
-H "X-Auth-Token: ijFlJ1yfidXhwEYY284Anoq_iEsOeMMVCupzNhX22tB" \
-H "X-User-Id: hw5DThnhQmxDWnavu"
{% hint style="info" %} For some file types, when uploading via curl, you may need to set the mime type.
With some file types, curl will upload the file as application/octet-stream
. You can pass a custom mime type like this: -F "file=@file.wav;type=audio/wav"
to specify the type.
{% endhint %}
{
"message": {
"_id": "XhqGxkXYtcYba2F9K",
"rid": "GENERAL",
"ts": "2022-06-29T07:34:33.736Z",
"msg": "This is a message with a file",
"file": {
"_id": "pw6oyrjBStWwMdeMv",
"name": "example.txt",
"type": "text/plain"
},
"files": [
{
"_id": "pw6oyrjBStWwMdeMv",
"name": "example.txt",
"type": "text/plain"
}
],
"attachments": [
{
"ts": "1970-01-01T00:00:00.000Z",
"title": "example.txt",
"title_link": "/file-upload/pw6oyrjBStWwMdeMv/example.txt",
"title_link_download": true,
"type": "file",
"description": "Simple text file"
}
],
"u": {
"_id": "g8aroJivN5R32TxCm",
"username": "rodriq",
"name": "Rodriq"
},
"_updatedAt": "2022-06-29T07:34:33.811Z",
"urls": [],
"md": [
{
"type": "PARAGRAPH",
"value": [
{
"type": "PLAIN_TEXT",
"value": "This is a message with a file"
}
]
}
]
},
"success": true
}
Any of the following errors can occur:
- Authorization: Requires an authentication token for the request to be made.
- Invalid Field: Occurs when the file parameter is invalid.
- Unknow Key: Occurs when any extra payload is sent in the request.
{% tabs %} {% tab title=" Authorization" %}
{
"success": false,
"error": "unauthorized"
}
{% endtab %}
{% tab title="Invalid Field" %}
{
"success": false,
"error": "[invalid-field]",
"errorType": "invalid-field"
}
{% endtab %}
{% tab title="Unknown Key" %}
{
"success": false,
"error": "Match error: Unknown key in field dasd"
}
{% endtab %} {% endtabs %}
Version | Description |
---|---|
1.0.0 | Return Message object on file upload |
0.62.0 | Added |