NOTE: this is still a draft, so it's subject to changes. This alert will be removed as soon as final version will be available

🌐@hsuite/ipfs - InterPlanetary File System Integration

🌌 Enterprise-grade IPFS integration with dual-provider architecture and comprehensive file management

Comprehensive NestJS module for IPFS (InterPlanetary File System) providing seamless integration with direct node access, HTTP gateways, content pinning, file uploads, and persistent storage management with MongoDB tracking.


πŸ“š Table of Contents


✨ Quick Start

Installation

npm install @hsuite/ipfs

Basic Setup

Basic Usage


πŸ—οΈ Architecture

Dual Provider System

πŸ–₯️ Node Provider

  • Direct IPFS Node - HTTP client connection to IPFS daemon

  • Content Pinning - Persistent storage with ownership tracking

  • Pin Management - MongoDB persistence for pin records

  • Node Status - Health monitoring and network information

🌐 Gateway Provider

  • HTTP Gateways - Multiple gateway support with automatic fallback

  • High Availability - Redundant gateway access for reliability

  • Image Optimization - Specialized image URL generation

  • Metadata Processing - Base64 decoding and URL resolution

Core Services

πŸ“ IpfsService

  • Content Retrieval - Get data and files from IPFS with type detection

  • File Upload - Stream-based file uploads with Multer integration

  • Pin Management - Pin/unpin content with ownership tracking

  • Provider Fallback - Automatic switching between node and gateway

πŸ—„οΈ Pin Management

  • MongoDB Integration - Persistent storage of pin records

  • Ownership Tracking - Web3 entity association with content

  • Timestamp Records - Pin creation and management timestamps

  • Event System - Real-time notifications for IPFS operations

πŸ”Œ REST API Controller

  • File Upload Endpoints - Multipart file upload with validation

  • Content Access - RESTful content retrieval and management

  • Pin Operations - HTTP endpoints for pinning and unpinning

  • Metadata Services - Specialized metadata processing endpoints

Module Structure


πŸ”§ API Reference

IpfsService

Core Methods

get(cid: string): Promise<{data: any}>

  • Retrieves content from IPFS by Content Identifier

  • Parameters: cid: string - IPFS Content Identifier

  • Returns: Retrieved content data (JSON parsed if possible)

  • Fallback: Node provider β†’ Gateway provider

getFile(ipfsUrl: string): Promise<{data: {buffer: Buffer, type: FileTypeResult}}>

  • Retrieves file with type detection

  • Parameters: ipfsUrl: string - IPFS URL or CID

  • Returns: File buffer and detected MIME type

  • Fallback: Gateway provider β†’ Node provider

pin(cid: string, owner: IAuth.ICredentials.IWeb3.IEntity): Promise<any>

  • Pins content to IPFS with ownership tracking

  • Parameters: CID and Web3 entity owner credentials

  • Returns: Pin operation result

  • Storage: MongoDB pin record creation

unpin(cid: string, owner: IAuth.ICredentials.IWeb3.IEntity): Promise<any>

  • Unpins content from IPFS (owner verification)

  • Parameters: CID and owner credentials for verification

  • Returns: Unpin operation result

  • Validation: Owner authorization check

uploadAndPin(file: Multer.File, session: IAuth.ICredentials.IWeb3.IEntity): Promise<string>

  • Uploads file to IPFS and pins with metadata

  • Parameters: Multer file object and session credentials

  • Returns: CID of uploaded and pinned content

  • Features: Stream processing, automatic pinning, metadata storage

REST API Endpoints

Content Operations

Retrieve content from IPFS by CID

File Operations

Retrieve files and upload new files to IPFS

Pin Management

Pin and unpin content with ownership verification

Metadata Operations

Retrieve and process metadata with image URL resolution

Provider Interfaces

Node Provider Interface

Gateway Provider Interface

Pin Record Interface


πŸ“– Guides

IPFS Node Setup Guide

Configure local or remote IPFS nodes for direct integration. Comprehensive setup guide covering IPFS node installation, configuration optimization, network connectivity, clustering setup, and enterprise-grade IPFS deployment for high-availability content storage.

Gateway Configuration Guide

Set up multiple IPFS gateways for high availability access. Advanced configuration guide covering gateway load balancing, failover mechanisms, CDN integration, performance optimization, and enterprise gateway management for reliable content delivery.

File Upload Guide

Implement secure file uploads with size limits and validation. Detailed implementation guide covering file validation, size restrictions, MIME type checking, secure upload workflows, metadata management, and enterprise file handling best practices.


🎯 Examples

File Upload and Management

Content Pinning Service

Image and Media Service

IPFS Gateway Service

Event-Driven IPFS Service


πŸ”— Integration

Required Dependencies

Environment Variables

Module Configuration

Docker IPFS Node Setup

Integration with HSuite Ecosystem


🌌 Decentralized Storage: Complete IPFS integration with enterprise-grade reliability and automatic fallback mechanisms.

πŸ“ Advanced File Management: Stream-based uploads, type detection, thumbnail generation, and comprehensive metadata handling.

πŸ” Ownership Tracking: Web3-native content ownership with MongoDB persistence and event-driven notifications.


Built with ❀️ by the HSuite Team Copyright © 2025 HSuite. All rights reserved.

Last updated