w3s
is a server-side application that offers developers a streamlined way to upload files to IPFS via @web3-storage
. It also provides a text-to-speech (TTS) service, converting raw text into audio and returning the content identifier (CID) for easy access and retrieval.
- IPFS File Upload: Effortlessly upload single or multiple files to IPFS with CIDs returned for easy retrieval.
- Text-to-Speech Conversion: Send raw text to the server, which returns an audio file as a CID after conversion.
- Integrated Web3.Storage Client: Utilizes
@web3-storage
for reliable IPFS file handling.
-
Clone the Repository
git clone https://github.com/rockyessel/w3s.git cd w3s
-
Install Dependencies
npm install
-
Environment Setup Copy the provided
.env.example
file and fill in your Web3.Storage and AWS credentials.cp .env.example .env
Populate your .env
file with the necessary configuration settings:
AWS_ACCESS_KEY_ID
- AWS Access Key for any AWS-based services.AWS_REGION
- AWS region for accessing AWS resources.AWS_SECRET_ACCESS_KEY
- AWS Secret Key for secure access.WEB3STORAGE_EMAIL
- Registered email address with Web3.Storage.WEB3STORAGE_SPACE_DID
- Decentralized Identifier (DID) for space in Web3.Storage.
These values are essential for the Web3.Storage integration and for accessing AWS services.
Start the server with:
npm run dev
The server will be running on http://localhost:8000
by default (or the port specified in your .env
file).
- Endpoint:
POST /api/v1/file
- Description: Upload a single file to IPFS.
- Request Body:
file
- File to upload (multipart/form-data). - Response: JSON containing the CID of the uploaded file.
- Endpoint:
POST /api/v1/files
- Description: Upload multiple files to IPFS in a single request.
- Request Body:
files[]
- Array of files (multipart/form-data). - Response: JSON array with CIDs for each uploaded file.
- Endpoint:
POST /api/v1/tts
- Description: Convert raw text into an audio file and store it on IPFS.
- Request Body:
text
- Raw text to convert into audio. - Response: JSON containing the CID of the generated audio file.
To utilize Web3.Storage effectively, w3s
comes with a helper function for initializing the client.
import { w3sClient } from '/lib/configs/w3s.js';
const client = await w3sClient();
// Now you can use the client to upload files to IPFS
The client:
- Logs in to Web3.Storage using the configured email.
- Sets the current space based on the DID provided.
- Checks and ensures an active payment plan is in place. Offers free plan (5.0 GB)
w3s
is hosted and deployed on Render.com, which offers flexible deployment options for scaling web applications and APIs with features like autoscaling, private networking, and zero-downtime deploys.
- Automatic Deploys: Automatically redeploys the app on each push to the main branch, ensuring the latest code is always live.
- Zero Downtime: Render provides zero-downtime deploys, minimizing disruption during updates.
- Scalability: The platform supports load-based autoscaling, enabling
w3s
to handle increased traffic seamlessly. - Managed PostgreSQL and Redis: For data storage and caching needs, Render offers integrated, managed data services with high availability and compliance standards (e.g., SOC 2, GDPR).
curl -X POST "http://localhost:8000/api/v1/file" \
-H "Content-Type: multipart/form-data" \
-F "file=@path/to/your-file"
Feel free to fork, contribute, or raise issues to improve the project. We welcome contributions to expand functionality and documentation.
This project is licensed under the MIT License. See the LICENSE file for details.