Install
Install the SDK with your package manager of choice.
npm install @fluxsave/sdk
Authentication
All requests use API key + secret headers. You can set them in the constructor. The Node SDK also supports setAuth for runtime updates.
const client = new FluxsaveClient({
baseUrl: 'https://fluxsaveapi.lutheralien.com',
apiKey: 'fs_123',
apiSecret: 'sk_456',
});
client.setAuth('fs_new', 'sk_new');
SDKs
Each SDK is open source with its own repo, changelog, and examples.
Upload
Upload a single file or multiple files. Image transforms are optional.
// Single file
await client.uploadFile(file, {
name: 'marketing-hero',
transform: true,
});
// Multiple files
await client.uploadFiles([
{ file: image1, filename: 'one.png' },
{ file: image2, filename: 'two.png' },
]);
List & delete
Fetch files and remove them by ID.
const list = await client.listFiles();
const first = list.data[0];
if (first) {
await client.deleteFile(first._id || first.fileId);
}
Errors
Errors throw FluxsaveError with status and data for easier debugging.
try {
await client.uploadFile(file);
} catch (err) {
if (err instanceof FluxsaveError) {
console.log(err.status, err.message);
}
}
Examples
Browser upload
const file = input.files[0];
await client.uploadFile(file);
Node upload
import { readFile } from 'node:fs/promises';
import { fileFromBuffer } from '@fluxsave/sdk';
const buffer = await readFile('./logo.png');
const file = fileFromBuffer(buffer, 'logo.png', 'image/png');
await client.uploadFile(file);
SDK config
Control timeouts and retry behavior for flaky networks.
const client = new FluxsaveClient({
baseUrl: 'https://fluxsaveapi.lutheralien.com',
apiKey: 'fs_xxx',
apiSecret: 'sk_xxx',
timeoutMs: 30000,
retry: { retries: 2, retryDelayMs: 400 },
});
Changelog
0.1.0
- Initial SDK release
- Uploads, listing, updates, metrics
- Retries + timeout support