Upload a file

Upload a single file and get the corresponding URI.

POST https://bgst.chat.bundjugend.de/api/v1/user_uploads

Initially, only you will be able to access the link. To share the uploaded file, you'll need to send a message containing the resulting link. Users who can already access the link can reshare it with other users by sending additional Zulip messages containing the link.

Usage examples

#!/usr/bin/env python3

import zulip

# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")

# Upload a file
with open(path_to_file, "rb") as fp:
    result = client.upload_file(fp)

# Share the file by including it in a message.
client.send_message(
    {
        "type": "stream",
        "to": "Denmark",
        "topic": "Castle",
        "content": "Check out [this picture]({}) of my castle!".format(result["uri"]),
    }
)
print(result)

curl -sSX POST https://bgst.chat.bundjugend.de/api/v1/user_uploads \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY \
    -F filename=@/path/to/file

Parameters

As described above, the file to upload must be provided in the request's body.

Maximum file size

The maximum file size for uploads can be configured by the administrator of the Zulip server by setting MAX_FILE_UPLOAD_SIZE in the server's settings. MAX_FILE_UPLOAD_SIZE defaults to 25MB.

Response

Return values

  • uri: string

    The URI of the uploaded file.

Example response

A typical successful JSON response may look like:

{
    "msg": "",
    "result": "success",
    "uri": "/user_uploads/1/4e/m2A3MSqFnWRLUf9SaPzQ0Up_/zulip.txt"
}