Fuselage
Upload File to a Room
REST API Upload Methods
Post a message with the attached file to a dedicated room.
URL
Requires Auth
HTTP Method
/api/v1/rooms.upload/:rid
yes
POST

Payload

Argument
Example
Required
Description
file
$HOME/example.txt
Required
A file name to upload
msg
This is a message with a file
Optional
A message text
description
Simple text file
Optional
A description of the file
tmid
vg3h21v31v23
Optional
The thread message id (if you want upload a file to a thread)

Example Call

1
curl "http://localhost:3000/api/v1/rooms.upload/GENERAL" \
2
-F file=@$HOME/example.txt \
3
-F "msg=This is a message with a file" \
4
-F "description=Simple text file" \
5
-H "X-Auth-Token: ijFlJ1yfidXhwEYY284Anoq_iEsOeMMVCupzNhX22tB" \
6
-H "X-User-Id: hw5DThnhQmxDWnavu"
Copied!
Note: For some file types if 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 "[email protected];type=audio/wav"

Example Result

1
{
2
"message": {
3
"_id": "HxX7qtrm6azSaMChG",
4
"rid": "GENERAL",
5
"ts": "2019-03-24T20:28:02.501Z",
6
"msg": "This is a message with a file and I want to test it",
7
"file": {
8
"_id": "RwiWv3waLHfXLW3mj",
9
"name": "temp.txt",
10
"type": "text/plain"
11
},
12
"attachments": [
13
{
14
"ts": "1970-01-01T00:00:00.000Z",
15
"title": "temp.txt",
16
"title_link": "/file-upload/RwiWv3waLHfXLW3mj/temp.txt",
17
"title_link_download": true,
18
"type": "file",
19
"description": "Simple text file"
20
}
21
],
22
"u": {
23
"_id": "abJaoNiibGs7gP9fe",
24
"username": "knrt10",
25
"name": "knrt10"
26
},
27
"_updatedAt": "2019-03-24T20:28:02.558Z"
28
},
29
"success": true
30
}
Copied!
A picture with a message

Example HTTP dump

1
POST /api/v1/rooms.upload/GENERAL HTTP/1.1
2
Host: 192.168.2.71:3000
3
User-Agent: curl/7.45.0
4
Accept: */*
5
X-Auth-Token: ijFlJ1yfidXhwEYY284Anoq_iEsOeMMVCupzNhX22tB
6
X-User-Id: hw5DThnhQmxDWnavu
7
Content-Length: 457
8
Expect: 100-continue
9
Content-Type: multipart/form-data; boundary=------------------------f2ee26fd9d793455
10
11
--------------------------f2ee26fd9d793455
12
Content-Disposition: form-data; name="file"; filename="example.txt"
13
Content-Type: text/plain
14
15
This text file contains a text.
16
--------------------------f2ee26fd9d793455
17
Content-Disposition: form-data; name="msg"
18
19
This is a message with a file
20
--------------------------f2ee26fd9d793455
21
Content-Disposition: form-data; name="description"
22
23
Simple text file
24
--------------------------f2ee26fd9d793455--
25
26
HTTP/1.1 200 OK
27
Access-Control-Allow-Origin: *
28
X-Instance-ID: 6vZ3BLNJ8jnPZfYYx
29
Cache-Control: no-store
30
Pragma: no-cache
31
content-type: application/json
32
Vary: Accept-Encoding
33
Date: Sun, 28 Jan 2018 11:08:18 GMT
34
Connection: keep-alive
35
Transfer-Encoding: chunked
36
37
{
38
"message": {
39
"_id": "HxX7qtrm6azSaMChG",
40
"rid": "GENERAL",
41
"ts": "2019-03-24T20:28:02.501Z",
42
"msg": "This is a message with a file and I want to test it",
43
"file": {
44
"_id": "RwiWv3waLHfXLW3mj",
45
"name": "temp.txt",
46
"type": "text/plain"
47
},
48
"attachments": [
49
{
50
"ts": "1970-01-01T00:00:00.000Z",
51
"title": "temp.txt",
52
"title_link": "/file-upload/RwiWv3waLHfXLW3mj/temp.txt",
53
"title_link_download": true,
54
"type": "file",
55
"description": "Simple text file"
56
}
57
],
58
"u": {
59
"_id": "abJaoNiibGs7gP9fe",
60
"username": "knrt10",
61
"name": "knrt10"
62
},
63
"_updatedAt": "2019-03-24T20:28:02.558Z"
64
},
65
"success": true
66
}
Copied!

Change Log

Version
Description
1.0.0
Return Message object on file upload
0.62.0
Added
Last modified 3mo ago
Export as PDF
Copy link
Edit on GitHub