Frontend
React SDK
Documentation for ApexxCloud React SDK
Installation
useApexxCloud Hook
A custom hook for granular control over the upload process.
Basic Usage
Multipart Upload Example
Hook Return Value
Property | Type | Description |
---|---|---|
upload | (getSignedUrl: GetSignedUrlFn, file: File, options?: UploadOptions) => Promise<any> | Function for single file upload |
uploadMultipart | (getSignedUrl: GetSignedUrlFn, file: File, options?: MultipartUploadOptions) => Promise<any> | Function for multipart upload |
transformImage | TransformBuilder | Builder for image transformations |
transformVideo | VideoTransformBuilder | Builder for video transformations |
transformDocument | DocumentTransformBuilder | Builder for document transformations |
transformWithString | (path: string, transformations: string | string[]) => string | Direct transformation using strings |
Upload Options
Option | Type | Description |
---|---|---|
signal | AbortSignal | AbortSignal for cancelling upload |
onStart | (event: StartEvent) => void | Called when upload starts |
onProgress | (event: ProgressEvent) => void | Called during upload progress |
onComplete | (event: CompleteEvent) => void | Called when upload completes |
onError | (event: ErrorEvent) => void | Called if upload fails |
Multipart Upload Options
Includes all Upload Options plus:
Option | Type | Description |
---|---|---|
partSize | number | Size of each part in bytes (default: 5MB) |
concurrency | number | Number of concurrent part uploads (default: 3) |
onPartComplete | (part: PartCompleteEvent) => void | Called when a part completes |
Backend Implementation
See the JavaScript SDK documentation for details on implementing the backend signed URL endpoint.
File Uploader Component
The SDK provides a pre-built FileUploader
component that you can use out of the box:
Component Props
Prop | Type | Description |
---|---|---|
getSignedUrl | GetSignedUrlFn | Function to get signed URLs from your backend |
onUploadComplete | (response: any) => void | Called when upload completes successfully |
onUploadError | (error: Error) => void | Called when upload fails |
multipart | boolean | Enable multipart upload for large files |
accept | Record<string, string[]> | Accepted file types |
maxSize | number | Maximum file size in MB |
Custom Implementation
If you want to customize the uploader or build your own, here’s the complete implementation of our FileUploader component that you can use as a reference:
This implementation includes:
- Drag and drop support
- Upload progress tracking
- Error handling
- File type and size validation
- Upload cancellation
- Responsive design
- Accessibility features
Requirements
- React 16.8+ (Hooks support)
- @apexxcloud/sdk-js as a peer dependency
Transformations
Image Transformations
Video Transformations
Document Transformations
For detailed information about available transformation options, see the JavaScript SDK documentation.