Overview
Uploads an image to Replyke storage. The server processes the image using Sharp, generates named variants according to the specified mode, and returns anImage object with proxy URLs for all variants.
Works in both browser and React Native environments. Provides upload progress tracking.
Requires an authenticated user. The hook uses the private axios instance and will throw if no session is active.
Usage Example
Parameters
uploadImage(file, options) accepts two arguments:
The image to upload. In the browser, pass a standard
File object. In React Native, pass { uri, name, type? }.Processing configuration. Must include a
mode field. See Processing Modes below.Common Options (all modes)
JPEG/WebP quality, 1–100. Defaults to
85.Output format for all variants. Defaults to
"webp".Whether to remove EXIF metadata from the output. Defaults to
true.Storage path segments. The file is stored under the joined path. Defaults to
["images", <fileId>].Associates the file with an entity for cascade deletion.
Associates the file with a comment for cascade deletion.
Associates the file with a space for cascade deletion.
Called with upload percentage (0–100) during the multipart upload.
Processing Modes
exact-dimensions
Each variant has an explicit pixel width and height.
aspect-ratio-width-based
All variants share a fixed aspect ratio. You specify widths; heights are computed.
aspect-ratio-height-based
All variants share a fixed aspect ratio. You specify heights; widths are computed.
original-aspect
Preserves the original image’s aspect ratio. You specify the longest-edge size for each variant.
multi-aspect-ratio
Generates variants across multiple aspect ratios with explicit sizes.
Returns
Async function that performs the upload and returns an
Image object on success.true while the upload is in progress.Upload percentage (0–100). Resets to
0 when the upload finishes.
