The images module handles synchronization of media files between Buttondown’s image storage and local filesystem.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/buttondown/cli/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Images are fetched from the Buttondown API and stored locally in themedia/ directory. The module provides upload functionality for local images to be pushed to Buttondown.
Types
Image
Based on the Buttondown APIImage schema from OpenAPI specification.
id- Unique identifierimage- URL to the image filefilename- Original filenamecreated- Creation timestamp
Functions
uploadImage()
Uploads a local image file to Buttondown.Configuration object containing API credentials and settings
Absolute path to the local image file to upload
Unique identifier for the uploaded image
Public URL where the image is hosted
Filename of the uploaded image
Supported Formats
The function automatically detects MIME types based on file extension:| Extension | MIME Type |
|---|---|
.gif | image/gif |
.jpeg, .jpg | image/jpeg |
.png | image/png |
.svg | image/svg+xml |
.webp | image/webp |
| Other | application/octet-stream |
Example
Error Handling
Throws an error if:- The file cannot be read
- The upload request fails
- The API returns an error response
Resource Objects
REMOTE_IMAGES_RESOURCE
Handles image operations with the Buttondown API.Methods
get(configuration) Fetches all images from the Buttondown API with automatic pagination.Configuration with API credentials
Array of all images from the API
- Fetches images in pages of 100 (defined by
PAGE_SIZE) - Continues until all pages are retrieved
- Returns complete array of all images
uploadImage() function for individual uploads instead.
LOCAL_IMAGES_RESOURCE
Handles image operations with local filesystem.Methods
get(configuration) Local image reading is not implemented (returns empty array).Empty array (always returns
[])media/ directory.
Array of image objects to download
Configuration with directory path
Operation result (always returns zeros)
Behavior
- Creates
media/directory if it doesn’t exist - Downloads each image from its URL
- Saves with original filename from URL
- Overwrites existing files with same name
Example
IMAGES_RESOURCE
Combined resource group for image synchronization.Properties
Resource identifier:
"images"Remote API resource handler
Local filesystem resource handler
Usage Patterns
Syncing Images from Remote to Local
Uploading Local Image
Constants
EXTENSION_TO_MIME
Mapping of file extensions to MIME types:uploadImage() to set correct Content-Type header.