Space works as permanent storage for all uploaded files. After an application uploads a file to Space, it receives an attachment ID. It can then use this ID to attach the file or add a file link, e.g., to issues or messages. Space supports all basic file formats like image, video, text, and binary files.
To upload a file to Space, the application must send a POST request to the following endpoint:
filename– (Required) the name of the file to upload.
spaceMediaType– (Optional) the usage context for the uploaded file. If specified, Space will generate a file preview appropriate for the intended context, such as a chat message or an issue. If not (or if the specified context does not match the actual context where the file is used), the file will be shown as is without a preview. Possible values:
issue-image-attachment– the file is an image attached to an issue.
chat-image-attachment– the file is an image attached to a chat message.
chat-video-attachment– the file is a vide attached to a chat message.
Content-TypeHTTP header is required.
The file must be sent in the request body.
The bearer token authorization is required. Permissions are not checked, so any authorized client can upload files to Space. Learn how to get a token
In the response, the application receives a
stringwith the attachment ID. Learn how you can use this ID to reference the uploaded files
There's no specific method for uploading files in the Kotlin Space SDK. Instead, you can use the
ktorClient that is built into the
SpaceClient class to send a POST request to the upload endpoint.
Reference uploaded files
Once your application has the file's attachment ID, it can reference the file in Space.
Attachment to a message
When sending a message, add the file as an attachment by specifying its ID in the
attachments field. Note that in Space you can send messages not only to chat channels or team members, but also to issues, documents, code reviews, and other modules that support commenting.
All message attachments are private by default. They are available only to the users within the current scope, for example, to the members of the current chat channel. To make an attachment public, use the
getPublicUrl API method.
Attachment to an issue
When creating an issue, add the file as an attachment by specifying its ID in the
You can also add attachments to existing issues:
In all places in Space that support Markdown, you can insert a link to a file by specifying its ID. For example:
[download the file]/d/here_goes_attachment_id
If the attachment is public, you can share a link to it with anyone: