# Upload Files
The `upload` command is the core functionality of PinMe. It allows you to upload single files or entire directories to the IPFS network and optionally bind them to a PinMe subdomain or your own DNS domain.

Authentication is required before you upload. For local use, run `pinme login` first. For CI or scripts, configure `pinme set-appkey` first.

## Command Syntax

```bash
pinme upload [path] [--domain <name>]
pinme upload [path] [-d <name>]
```

## Parameters

- `path` (optional): Path to the file or directory to upload
- `-d, --domain <name>` (optional): PinMe subdomain or DNS domain to bind after upload

## Upload Types

### 1. Interactive Upload

Start upload without specifying a path to enter interactive mode:

```bash
pinme login
pinme upload
```

PinMe will prompt you to select a file or directory.

### 2. Upload Single File

```bash
# Log in first
pinme login

# Upload a specific file
pinme upload ./index.html

# Upload with domain binding
pinme upload ./index.html --domain my-portfolio

# Using short flag
pinme upload ./index.html -d my-portfolio
```

### 3. Upload Directory

```bash
# Log in first
pinme login

# Upload entire directory
pinme upload ./my-website

# Upload directory with domain
pinme upload ./dist --domain my-app

# Upload nested directory
pinme upload ./build/static --domain assets
```

## Supported File Types

PinMe accepts any file type:

- Music (MP3, WAV, etc.)
- Images (JPG, PNG, GIF, etc.)
- Websites (HTML, CSS, JS)
- Videos, documents, config files
- And more...

## Size Limits

- **Single file**: Maximum 200 MB
- **Total directory**: 1 GB

## Upload Examples

### Example 1: Deploy a Static Website

```bash
# Build your project first
npm run build

# Upload the build output
pinme upload ./dist --domain my-awesome-site
```

### Example 2: Upload Documentation

```bash
# Upload docs folder
pinme upload ./docs --domain my-project-docs
```

### Example 3: Share a Single File

```bash
# Upload a PDF for sharing
pinme upload ./report.pdf
```

## What Happens During Upload?

### 1. File Processing
- PinMe reads and validates your files
- Calculates file sizes against limits
- Generates file structure for IPFS

### 2. IPFS Upload
- Files are added to IPFS & Filecoin
- Content is identified by cryptographic hash (CID)
- Files are pinned to ensure persistence

### 3. Domain Binding (if specified)
- PinMe creates or updates the requested PinMe subdomain or DNS binding
- The bound address points to your uploaded content
- Takes 1-2 minutes to propagate

### 4. Response Information

After successful upload, you'll receive:

```bash
                              

uploading /xxx.md to ipfs...
✔ Upload completed [████████████████████] 100% (9s)

  ____                                              __           _ 
 / ___|   _   _    ___    ___    ___   ___   ___   / _|  _   _  | |
 \___ \  | | | |  / __|  / __|  / _ \ / __| / __| | |_  | | | | | |
  ___) | | |_| | | (__  | (__  |  __/ \__ \ \__ \ |  _| | |_| | | |
 |____/   \__,_|  \___|  \___|  \___| |___/ |___/ |_|    \__,_| |_|
                                                                   

URL:
https://pinme.eth.limo/#/preview/U2FsdGVkX1_04_Hgws2BtGn0v7vUomlmN6L...


🎉 upload successful, program exit
```

## Upload Options and Flags

### Domain Binding
```bash
# Bind to a PinMe subdomain
pinme upload ./site --domain my-site

# Bind to a DNS domain
pinme upload ./site --domain docs.example.com

# Domain naming rules:
# - 3-63 characters
# - Lowercase letters, numbers, hyphens
# - Cannot start or end with hyphen
# - Must be unique across PinMe when using a PinMe subdomain
# - Binding a domain requires authentication and enough wallet balance
```

## Best Practices

### File Organization
```
my-project/
├── index.html          # Entry point
├── assets/
│   ├── css/
│   ├── js/
│   └── images/
└── dist/              # Build output
```

### Relative Paths
Use relative paths in your HTML/CSS/JS:

```html
<!-- Good -->
<link rel="stylesheet" href="./styles/main.css">
<img src="./images/logo.png">

<!-- Avoid absolute paths -->
<link rel="stylesheet" href="/styles/main.css">
```

### File Compression
- Compress images before upload
- Minimize CSS/JavaScript files
- Remove unused files and dependencies
