Skip to content

Save

The save method writes images to storage.

await floimg.save(image, './output.png');
ParameterTypeRequiredDescription
imageBlobYesThe image to save
pathstringYesDestination path (filesystem or URL)
// Relative path
await floimg.save(image, './output/chart.png');
// Absolute path
await floimg.save(image, '/var/www/images/chart.png');
await floimg.save(image, 's3://my-bucket/charts/monthly.png');

Requires AWS credentials via environment variables or AWS SDK configuration:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_REGION

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');

Returns void. Throws on error.

try {
await floimg.save(image, 's3://bucket/path.png');
} catch (error) {
console.error('Save failed:', error.message);
}

Common errors:

  • Path not writable - Filesystem permission error
  • Storage not configured - Missing credentials
  • Network error - Cloud storage connectivity issue