Skip to content
/ f2f Public

基于 cloudflare 的简单、快速、安全的点对点文件传输工具

License

Notifications You must be signed in to change notification settings

isnl/f2f

Repository files navigation

🚀 F2F.icu

Simple, Fast, and Secure Peer-to-Peer File Transfer Tool

English | 简体中文 | 日本語 | 한국어 | Français | Español | Deutsch

GitHub stars GitHub forks GitHub issues GitHub license PRs Welcome

Deploy with Cloudflare Pages Powered by Workers

🌐 Live Demo | 📖 Documentation | 🐛 Report Issues | 💡 Feature Requests


✨ Features

🚀 Lightning Fast
Powered by Cloudflare's global edge network with millisecond response times
🔐 6-Digit Share Code
Simple and memorable, with 2.18 billion combinations for security
📦 Large File Support
Single file up to 25MB, perfect for everyday needs
📝 Multiple Formats
Support for files, text, images, and various content types
📚 Batch Upload
Support multiple files (up to 100) and images (up to 25) at once
📦 ZIP Download
Download multiple files/images as a single ZIP package
⏱️ Auto-Deletion
Automatically deleted 1 minute after download to protect privacy
🆓 Completely Free
Based on Cloudflare's free tier, no credit card required
🎨 Beautiful Interface
Modern UI design with exceptional user experience
📱 Responsive Design
Perfect support for mobile, tablet, and desktop

🎯 Live Demo

👉 Visit: https://f2f.icu

Demo Available

📸 Preview

Click to view interface screenshots

Send Interface

Send Interface

Receive Interface

Receive Interface

🛠️ Technology Stack

Technology Description
⚡️ Cloudflare Pages Frontend static website hosting with global CDN acceleration
🔥 Cloudflare Workers Serverless backend API with edge computing
💾 Cloudflare KV Key-value storage with native TTL support
🎨 Tailwind CSS Modern CSS framework for rapid UI development
📝 TypeScript Type-safe JavaScript superset

🚀 Quick Start

Prerequisites

  • ✅ Node.js 16+
  • ✅ Cloudflare account (free tier is sufficient)
  • ✅ Git

One-Click Deploy

Method 1: Fork and Deploy (Recommended)

  1. Fork this repository

    Click the Fork button in the top right

  2. Connect to Cloudflare Pages

    • Login to Cloudflare Dashboard
    • Go to Workers & PagesCreate applicationPagesConnect to Git
    • Select your forked repository
    • Build configuration:
      • Build command: Leave blank (or npm run build)
      • Output directory: public
    • Click Save and Deploy
  3. Configure KV Storage

    • In Dashboard, go to Workers & PagesKV
    • Click Create a namespace, name it f2f-transfers
    • Go back to your Pages project → SettingsFunctionsKV namespace bindings
    • Add binding:
      • Variable name: TRANSFERS
      • KV namespace: Select f2f-transfers
    • Save and redeploy
  4. Done! 🎉

    Visit the domain provided by Cloudflare

Method 2: Local Development

# Clone repository
git clone https://github.com/isnl/f2f.git
cd f2f

# Install dependencies
npm install

# Create KV namespace
wrangler kv:namespace create "TRANSFERS"

# Configure wrangler.toml
# Add the generated namespace ID to wrangler.toml

# Start local development server
npm run dev

# Visit http://localhost:8788

Configuration File

Edit wrangler.toml:

name = "f2f-transfer"
compatibility_date = "2025-11-20"

pages_build_output_dir = "public"

[[kv_namespaces]]
binding = "TRANSFERS"
id = "your_kv_namespace_id_here"          # Replace with your production KV ID
preview_id = "your_preview_kv_id_here"    # Replace with your preview KV ID

📖 Usage Guide

📤 Send Files/Text

  1. Switch to Send tab
  2. Enter or generate a 6-digit share code (supports uppercase letters A-Z and numbers 0-9)
  3. Select content type:
    • File: Click to upload or drag and drop (supports multiple files, up to 100, total ≤25MB)
    • Text: Enter text content directly
    • Image: Select image or Ctrl/Cmd + V to paste screenshot (supports multiple images, up to 25)
  4. Click Create Share
  5. Copy the share code or link and send to recipient

📥 Receive Files/Text

  1. Switch to Receive tab
  2. Enter 6-digit pickup code
  3. Click Get Content
  4. Download options:
    • Single file: Auto-download
    • Multiple files/images: Choose to download individually or as a ZIP package
    • Text/Image: Direct preview display
  5. ⚠️ Content will be automatically deleted after 1 minute, please save promptly

⚙️ How It Works

graph LR
    A[Sender Upload] --> B[Convert to Base64]
    B --> C[Store in KV]
    C --> D[Generate Share Code]
    D --> E[Receiver Enters Code]
    E --> F[Read from KV]
    F --> G[Mark as Downloaded]
    G --> H[Set 1 Minute TTL]
    H --> I[Auto Delete]
Loading

Data Flow

  1. Upload Phase

    • File → Base64 encoding → Store in KV
    • Default TTL: 1 hour (auto-delete after 1 hour if not downloaded)
  2. Download Phase

    • Verify share code → Read data
    • Mark as downloaded → Update TTL to 1 minute
    • Auto-trigger browser download (files) or display (text/images)
  3. Cleanup Phase

    • KV automatically deletes expired data based on TTL
    • Zero maintenance cost

Why Choose KV Storage?

Feature KV Storage R2 Object Storage D1 Database
Single value size 25MB 5GB 1MB (needs sharding)
TTL support Native ❌ Manual implementation ❌ Manual implementation
Read/write latency Very low Low Lower
Free tier 100K reads/day Requires credit card 10 databases
Use case Temporary file storage Large file storage Structured data

🔒 Security

Item Description
🔢 Code Strength 6 characters (A-Z, 0-9), ~2.18 billion combinations
Data Retention Not downloaded: 1 hour / Downloaded: 1 minute
⚠️ Privacy Notice Not recommended for sensitive information (passwords, IDs, etc.)
🔐 Transfer Security Full HTTPS encryption

📊 Limitations

  • File Size: Maximum 25MB total
  • File Count: Up to 100 files or 25 images per transfer
  • Share Code Format: 6-digit uppercase letters or numbers (A-Z, 0-9)
  • Data Retention:
    • Not downloaded: Auto-delete after 1 hour
    • Downloaded: Auto-delete after 1 minute
  • KV Free Tier:
    • 100,000 reads per day
    • 1,000 writes per day
    • Sufficient for personal use

📝 API Documentation

POST /api/upload

Upload file or text

Request Parameters (FormData):

{
  code: string,       // 6-digit share code (required)
  type: 'file' | 'text' | 'files' | 'images',  // Content type (required)
  content: string,    // Content (required)
                      // - file: Base64 encoded file content
                      // - text: Plain text content
                      // - files: JSON array [{dataUrl, name, size, type}, ...]
                      // - images: JSON array [{dataUrl, name}, ...]
  fileName?: string   // File name (required when type=file)
}

Response:

{
  success: true,
  code: string,       // Share code
  message: string     // Status message
}

GET /api/download

Download file or get text

Request Parameters:

?code=ABC123  // 6-digit pickup code

Response:

{
  success: true,
  type: 'file' | 'text' | 'files' | 'images',
  content: string,      // Base64, text, or JSON array
  contentType: string,  // MIME type
  fileName?: string     // File name (returned when type=file)
}

🎨 Customization

Modify File Size Limit

Edit functions/api/upload.ts:

const maxSize = 25 * 1024 * 1024; // Modify to your desired size (bytes)

Modify Data Retention Time

Upload TTL (not downloaded):

// functions/api/upload.ts
expirationTtl: 3600 // 1 hour = 3600 seconds, customizable

Download TTL (downloaded):

// functions/api/download.ts
expirationTtl: 60 // 1 minute = 60 seconds, customizable

🚀 Performance Optimization

Frontend Optimization

  • ✅ Tailwind CSS on-demand loading
  • ✅ Lazy loading icons (Lucide Icons)
  • ✅ Responsive image preview
  • ✅ Debouncing and throttling

Backend Optimization

  • ✅ Edge computing (Cloudflare Workers)
  • ✅ Global CDN acceleration
  • ✅ Low-latency KV storage

Recommendations

  1. Enable Cloudflare's Brotli compression
  2. Configure custom domain with HTTPS
  3. Enable Cloudflare Analytics to monitor traffic
  4. Use Cloudflare Workers Analytics to monitor API performance

🤝 Contributing

We welcome all forms of contributions! 🎉

How to Contribute

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add some AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Submit Pull Request

Types of Contributions

  • 🐛 Report bugs
  • 💡 Suggest new features
  • 📖 Improve documentation
  • 🎨 Optimize UI/UX
  • ⚡️ Performance optimization
  • 🌍 Multi-language support

Development Guidelines

  • Follow TypeScript conventions
  • Keep code clean and readable
  • Add necessary comments
  • Test features before submitting

🌟 Acknowledgments

Thanks to the following technologies and projects:

📄 License

This project is licensed under the MIT License - see the LICENSE file for details

💬 Contact

❓ FAQ

Why not use R2 object storage?

R2 object storage requires credit card binding, while KV storage is completely free and ready to use. For temporary file transfers under 25MB, KV storage is sufficient with lower latency.

How to modify file size limit?

Modify the maxSize constant in functions/api/upload.ts. Note:

  • KV single value maximum is 25MB
  • Files over 25MB require R2 object storage
  • Larger files take longer to upload/download
Is data really secure?
  • ✅ All data stored on Cloudflare edge nodes with physical security
  • ✅ Full HTTPS encrypted transfer
  • ✅ Auto-deletion mechanism protects privacy
  • ⚠️ Small probability of 6-digit code being guessed
  • ⚠️ Not recommended for highly sensitive information (passwords, private keys, etc.)
Why 1-minute deletion after download instead of immediate?

Provides error tolerance time for users:

  • Avoids download failures due to network latency
  • Allows users to re-download once
  • 1-minute auto-deletion balances convenience and security

You can customize this time in the code.

Is the free tier sufficient?

More than enough for personal use:

  • KV Reads: 100,000 per day
  • KV Writes: 1,000 per day
  • Workers Requests: 100,000 per day

For teams or high-frequency use, you may need to upgrade to a paid plan.

Can I self-host?

Absolutely! This project is open source, you can:

  1. Fork this repository
  2. Deploy to your own Cloudflare account
  3. Customize domain and configuration
  4. Have full control over data and service
Does it support batch upload?

Yes! The current version supports batch upload:

  • Multiple files: Up to 100 files, total size not exceeding 25MB
  • Multiple images: Up to 25 images, total size not exceeding 25MB
  • Download options: Download individually or as a single ZIP package
How to view usage statistics?

In Cloudflare Dashboard you can view:

  • Workers Analytics: API call count, response time, etc.
  • KV Metrics: Read/write count, storage usage, etc.
  • Pages Analytics: Traffic, geographic distribution, etc.

⭐ Star History

Star History Chart


🌟 If this project helps you, please give it a Star!

Made with ❤️ by isnl

⬆ Back to Top

About

基于 cloudflare 的简单、快速、安全的点对点文件传输工具

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages