Frontend
JavaScript SDK
Documentation for ApexxCloud JavaScript SDK
Installation
Initialization
Backend Implementation
Your backend needs to implement an endpoint that generates signed URLs. Here’s an example using Node.js:
The endpoint should handle these types of requests:
Type | Description | Required Parameters | Example Response |
---|---|---|---|
upload | Single file upload | key, mimeType | https://api.apexxcloud.com/upload?signature=... |
start-multipart | Start multipart upload | key, totalParts, mimeType | https://api.apexxcloud.com/multipart/start?signature=... |
uploadpart | Upload individual part | uploadId, partNumber, key, totalParts | https://api.apexxcloud.com/multipart/{uploadId}/upload?signature=... |
completemultipart | Complete multipart upload | uploadId, key | https://api.apexxcloud.com/multipart/{uploadId}/complete?signature=... |
cancelmultipart | Cancel multipart upload | uploadId, key | https://api.apexxcloud.com/multipart/{uploadId}/cancel?signature=... |
File Upload
Basic Upload
Multipart Upload
Error Handling
The SDK provides detailed error information through the onError callback:
Multipart Upload Phases
The multipart upload process includes different phases where errors might occur:
Phase | Description |
---|---|
start | During the initialization of multipart upload |
upload | During the upload of individual parts |
complete | During the completion of multipart upload |
cancel | During attempt to cancel a failed upload |
Image Transformations
The SDK provides a powerful image transformation API that allows you to modify images on-the-fly:
Available Image Transformations
Transformation | Method | Parameters | Example |
---|---|---|---|
Width | width(value) | 1-5000px | .width(800) |
Height | height(value) | 1-5000px | .height(600) |
Crop | crop(mode) | ’fill’, ‘fit’, ‘scale’ | .crop('fill') |
Quality | quality(value) | 1-100 or auto modes | .quality('auto:good') |
Format | format(type) | ’auto’, ‘webp’, ‘jpeg’ | .format('webp') |
Blur | blur(radius) | 1-100 | .blur(20) |
Grayscale | grayscale() | - | .grayscale() |
Background | background(color) | hex or ‘transparent’ | .background('#ff0000') |
Border | border(width, style, color) | width, style, color | .border(2, 'solid', '#000') |
Radius | radius(value) | pixels or array | .radius(10) |
Opacity | opacity(value) | 0-100 | .opacity(50) |
Text Overlay | text(text, options) | text, options | .text('Hello', options) |
Image Overlay | overlay(path, options) | path, options | .overlay('logo.png', options) |
Overlay Options
Option | Type | Description | Supported Types |
---|---|---|---|
type | string | ’image’ or ‘video’ | Video only |
gravity | string | Position on target | All |
x | number | Horizontal offset | All |
y | number | Vertical offset | All |
scale | number | Scale factor | Image, Video |
width | number | Width in pixels | Image, Video |
height | number | Height in pixels | Image, Video |
opacity | number | Opacity (0-100) | All |
aspectRatio | string | Aspect ratio | Image, Video |
Text-specific options:
Option | Type | Description |
---|---|---|
font | string | Font family name |
size | number | Font size in pixels |
color | string | Text color (hex) |
Video Transformations
Similar to images, you can transform videos:
Available Video Transformations
Transformation | Method | Parameters | Example |
---|---|---|---|
Width | width(value) | 1-5000px | .width(1280) |
Height | height(value) | 1-5000px | .height(720) |
Format | format(type) | ’mp4’, ‘webm’, ‘mov’ | .format('mp4') |
Thumbnail | thumbnail(seekOffset) | seconds | .thumbnail(5.0) |
Crop | crop(mode) | ’crop’, ‘fill’, ‘fit’ | .crop('fill') |
Background | background(color) | hex or ‘blur’ | .background('blur') |
Text Overlay | text(text, options) | text, options | .text('Title', options) |
Image Overlay | overlay(path, options) | path, options | .overlay('logo.png', imageOpts) |
Video Overlay | overlay(path, options) | path, options | .overlay('intro.mp4', videoOpts) |
Overlay Options
Option | Type | Description | Supported Types |
---|---|---|---|
type | string | ’image’ or ‘video’ | Video only |
gravity | string | Position on target | All |
x | number | Horizontal offset | All |
y | number | Vertical offset | All |
scale | number | Scale factor | Image, Video |
width | number | Width in pixels | Image, Video |
height | number | Height in pixels | Image, Video |
opacity | number | Opacity (0-100) | All |
aspectRatio | string | Aspect ratio | Image, Video |
Text-specific options:
Option | Type | Description |
---|---|---|
font | string | Font family name |
size | number | Font size in pixels |
color | string | Text color (hex) |
Document Transformations
Transform and convert documents:
Available Document Transformations
Transformation | Method | Parameters | Example |
---|---|---|---|
Format | format(type) | ’pdf’, ‘docx’, ‘xlsx’, ‘pptx’ | .format('pdf') |
Quality | quality(mode) | ’auto:high’, ‘auto:standard’, ‘auto:low’ | .quality('auto:high') |
Compress | compress(mode) | ’high’, ‘medium’, ‘low’ | .compress('medium') |
Pages | pages(range) | number or range (‘1-3,5-7’) | .pages('1-3') |
Thumbnail | thumbnail(page) | Page number | .thumbnail(1) |
Chaining Transformations
You can chain multiple transformations together using the chain()
method:
Each transformation chain is applied sequentially, allowing for complex transformation pipelines.