Save
The save method writes images to storage.
Basic Usage
Section titled “Basic Usage”await floimg.save(image, './output.png');Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
image | Blob | Yes | The image to save |
path | string | Yes | Destination path (filesystem or URL) |
Storage Backends
Section titled “Storage Backends”Local Filesystem
Section titled “Local Filesystem”// Relative pathawait floimg.save(image, './output/chart.png');
// Absolute pathawait floimg.save(image, '/var/www/images/chart.png');Amazon S3
Section titled “Amazon S3”await floimg.save(image, 's3://my-bucket/charts/monthly.png');Requires AWS credentials via environment variables or AWS SDK configuration:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_REGION
Custom Storage
Section titled “Custom Storage”Register a custom storage adapter:
floimg.registerStorage({ scheme: 'custom', async save(blob, path) { // Your storage logic }});
await floimg.save(image, 'custom://path/to/image.png');Return Value
Section titled “Return Value”Returns void. Throws on error.
Error Handling
Section titled “Error Handling”try { await floimg.save(image, 's3://bucket/path.png');} catch (error) { console.error('Save failed:', error.message);}Common errors:
Path not writable- Filesystem permission errorStorage not configured- Missing credentialsNetwork error- Cloud storage connectivity issue