Overview
The forum system supports decentralized file storage using IPFS (InterPlanetary File System) via Pinata. Files can be attached to both posts and categories.File Upload Flow
IPFS Integration
Configuration
Set up environment variables for Pinata:.env
Upload to IPFS
src/lib/pinata.ts
Server Actions
Upload File
src/lib/actions/forum/attachments.ts
Upload Document from Base64
src/lib/actions/forum/attachments.ts
Get Attachments
src/lib/actions/forum/attachments.ts
Delete Attachment
src/lib/actions/forum/attachments.ts
Archive Attachment
src/lib/actions/forum/attachments.ts
React Hook Integration
src/hooks/useForum.ts
Database Schema
- Post Attachments
- Category Attachments
Attachment Types
Post Attachments
Attached to individual posts (replies):- Images embedded in post content
- Documents referenced in discussions
- Supporting materials for arguments
Category Attachments
Attached to categories (used for DUNA documents):- Quarterly reports
- Financial statements
- Governance documents
- Legal filings
File Type Support
Documents
Documents
- PDF (.pdf)
- Word (.doc, .docx)
- Text (.txt, .md)
- Spreadsheets (.xls, .xlsx, .csv)
Images
Images
- JPEG (.jpg, .jpeg)
- PNG (.png)
- GIF (.gif)
- WebP (.webp)
- SVG (.svg)
Archives
Archives
- ZIP (.zip)
- TAR (.tar, .tar.gz)
Timed Attachments
Attachments support reveal and expiration times for scheduled releases:Best Practices
Validate file types
Validate file types
Always validate file types on both client and server to prevent malicious uploads.
Set size limits
Set size limits
Enforce reasonable file size limits to prevent abuse (typically 10-50 MB).
Use content addressing
Use content addressing
IPFS automatically provides content addressing - files are identified by their hash.
Store metadata
Store metadata
Keep file metadata (name, size, type, uploader) in your database for quick access.
Handle CORS
Handle CORS
Ensure your IPFS gateway is configured to allow CORS for your domain.
Next Steps
DUNA Integration
Learn about DUNA-specific document management
Moderation
Moderate and manage uploaded attachments