Skip to content

Uploading Images

Uploading images at Zustack.

Learn how to upload images to Zustack using the API.

Before you begin, make sure you have:

  • A bucket created
  • A JWT signed with your API Key with the scope claim set to write.

ParameterTypeDescription
bucket_idstringThe ID of your target bucket.
accessstringCan be public or private.
webpstringyes to convert image to WebP, no to keep original format.
filefileThe image file to upload (image/*).

First, set your environment variables:

Terminal window
export BUCKET_ID=your_bucket_id
export JWT=your_jwt_token
export ACCESS=public
export WEBP=yes
export PATH_TO_FILE=@/path/to/image.jpg

Then make the request using curl:

Terminal window
curl -X POST "https://zustack.com/files/upload/image/${BUCKET_ID}" \
-H "Authorization: Bearer ${JWT}" \
-H "Content-Type: multipart/form-data" \
-F "access=${ACCESS}" \
-F "webp=${WEBP}" \
-F "file=${PATH_TO_FILE}"

FieldTypeDescription
file_idstringA unique ID for the uploaded file.
{
"file_id": "0393445a-a851-483d-bcc1-09f7371d9ea2"
}

Once the file is uploaded, Zustack will send relevant information about the file to the webhook only if it is configured.

The data sent will include:

  • file_id: The ID of the created file.
  • media_url: The URL of the file.
  • status: The status of the file.

Make sure your bucket’s webhook is properly set up to receive these notifications.