Installation
Install the Filejar client:Basic Setup
Initialize the Filejar client:Framework Recipes
Filejar works seamlessly with popular Node.js frameworks. Choose your framework to see framework-specific integration examples:Express
Learn how to integrate Filejar with Express.js using Multer for file uploads.
Hono
Fast and lightweight web framework with built-in file handling.
Fastify
High-performance framework with @fastify/multipart plugin.
NestJS
Enterprise-grade framework with decorators and dependency injection.
ElysiaJS
TypeScript-first framework with built-in type validation.
Uploading Files
Single File Upload
Upload a single file to Filejar:Multiple Files Upload
Upload multiple files at once:Working with File Buffers
If you have a file buffer (e.g., from an HTTP request or file system):Error Handling
Handle errors properly:File URL Construction
After uploading, construct the file URL using the key:Complete Example
Here’s a complete example of uploading a file:TypeScript Support
Filejar includes full TypeScript support:Best Practices
- Always check acknowledgment: Verify that the upload was acknowledged successfully before using the file.
-
Handle errors gracefully: Use try-catch blocks and check for
Filejar.APIErrorinstances. -
Store file metadata: Save the
keyandupload_idin your database for later retrieval. -
Use file URLs: Construct file URLs using
https://cdn.filejar.dev/${key}for client-side access. - Validate file types: Validate file types and sizes before uploading to avoid unnecessary API calls.