Uploading Images
Uploading images at Zustack.
Learn how to upload images to Zustack using the API.
Prerequisites
Section titled “Prerequisites”Before you begin, make sure you have:
- A bucket created
- A JWT signed with your API Key with the scope claim set to write.
Image Upload Request
Section titled “Image Upload Request”Form Data Parameters
Section titled “Form Data Parameters”| Parameter | Type | Description |
|---|---|---|
bucket_id | string | The ID of your target bucket. |
access | string | Can be public or private. |
webp | string | yes to convert image to WebP, no to keep original format. |
file | file | The image file to upload (image/*). |
Example Request
Section titled “Example Request”First, set your environment variables:
export BUCKET_ID=your_bucket_idexport JWT=your_jwt_tokenexport ACCESS=publicexport WEBP=yesexport PATH_TO_FILE=@/path/to/image.jpgThen make the request using curl:
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}"Response
Section titled “Response”Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
file_id | string | A unique ID for the uploaded file. |
Example Response
Section titled “Example Response”{ "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.