evenstaian-file-manager-sdk
v1.0.0
Published
This is the file manager SDK created to use IPFS and S3 as storage providers
Readme
File Manager SDK
A lightweight SDK for managing file uploads across multiple cloud storage providers, with built-in support for AWS S3 and IPFS (via Pinata).
Features
- Multi-provider support (AWS S3 and IPFS/Pinata)
- TypeScript definitions included
- Simple unified interface
- Comprehensive error handling
Quick Start
Installation
npm install file-manager-sdk
# or
yarn add file-manager-sdkBasic Usage
- Initialize
const { FileManagerServiceSdk } = require('file-manager-sdk');
const fileManager = new FileManagerServiceSdk();- Configure
await fileManager.files.config({
AWSConfigs: {
AccessKey: 'YOUR_AWS_KEY',
AccessSecret: 'YOUR_AWS_SECRET'
},
PinataConfigs: {
AccessKey: 'YOUR_PINATA_KEY',
AccessSecret: 'YOUR_PINATA_SECRET'
}
});- Upload Files
AWS S3:
const result = await fileManager.files.save('S3', {
originalname: 'example.jpg',
buffer: fileBuffer
}, 'my-bucket');IPFS:
const result = await fileManager.files.save('IPFS', {
originalname: 'example.jpg',
buffer: fileBuffer
}, null, {
name: 'My File',
description: 'File description'
});API Reference
files.config(params)
Configure storage providers credentials.
interface ConfigParams {
AWSConfigs?: {
AccessKey: string;
AccessSecret: string;
};
PinataConfigs?: {
AccessKey: string;
AccessSecret: string;
};
}files.save(storageType, file, bucket?, metadata?)
Upload a file to the specified storage provider.
interface FileData {
originalname: string;
buffer: Buffer;
}
type Response = Promise<{
data?: any;
error?: string;
}>;Parameters:
storageType: 'S3' | 'IPFS'file: FileDatabucket: string (required for S3)metadata: object (required for IPFS)
Error Handling
The SDK returns structured responses:
{
data?: any; // Success data
error?: string // Error message if failed
}Contributing
We're open to contributions! If you'd like to improve this SDK, here are some ways you can contribute:
- New Storage Providers: Help us expand support for more cloud storage solutions
- Bug Fixes: Found a bug? Open an issue or submit a fix
- Documentation: Help improve or translate the documentation
- Features: Suggest or implement new features
- Examples: Add more example use cases
Please feel free to submit pull requests or create issues for any improvements you'd like to see.
Development Setup
- Fork the repository
- Clone your fork
- Install dependencies:
npm install - Make your changes
- Run tests:
npm test - Submit a pull request
We appreciate any contributions, whether it's code, documentation, or bug reports!
Author
Evens Taian
License
MIT License
