Files
claudeskill/skills/minio-upload/SKILL.md
Misaka Company 51eae214cc Add file conflict handling to minio-upload skill
Implement comprehensive file conflict detection and resolution:
- Check for existing files before upload using mc stat (fixes mc ls bug)
- Interactive prompt when conflict detected: overwrite, skip, backup, rename
- Command-line options for non-interactive use: --force, --skip, --backup, --rename
- Auto-rename with numeric suffix when file exists
- Backup existing files with .bak extension before overwriting
- Update SKILL.md with conflict handling documentation and examples

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-28 13:45:43 +08:00

119 lines
4.4 KiB
Markdown

---
name: minio-upload
description: Upload files to Obsidian vaults via MinIO obsidian bucket. Use when user asks to upload files to Obsidian, transfer notes to vaults, sync markdown files to Obsidian, or specify a particular vault destination. The obsidian bucket serves as the sync directory for Obsidian note-taking app.
---
# MinIO Upload
Upload files to Obsidian vaults through the MinIO obsidian bucket. This bucket serves as the synchronization directory for the Obsidian note-taking application, where each top-level directory represents a separate vault.
## Quick Start
Upload a file to the default `main` vault:
```bash
.claude/skills/minio-upload/scripts/upload_to_obsidian.sh path/to/file.md
```
Upload to a specific vault:
```bash
.claude/skills/minio-upload/scripts/upload_to_obsidian.sh path/to/file.md "journal"
```
## File Conflict Handling
**CRITICAL**: When a file with the same name already exists in the target vault, the script will prompt you to choose an action (unless an option is specified).
### Interactive Prompt (Default)
If the file exists and no option is provided, you'll see:
```
⚠️ File 'filename.md' already exists in vault 'main'
Choose an action:
[o] Overwrite - Replace existing file
[s] Skip - Cancel upload
[b] Backup - Backup existing file (.bak) then overwrite
[r] Rename - Upload with new name (adds numeric suffix)
```
### Command-Line Options
You can specify the behavior explicitly to skip the prompt:
- `--force` - Overwrite existing files without prompting
- `--skip` - Skip upload if file already exists
- `--backup` - Backup existing file (creates `.bak` file) before overwriting
- `--rename` - Automatically rename with numeric suffix (e.g., `file-1.md`, `file-2.md`)
### Examples
```bash
# Force overwrite without prompting
upload_to_obsidian.sh file.md main --force
# Skip if file exists
upload_to_obsidian.sh file.md journal --skip
# Backup before overwriting
upload_to_obsidian.sh file.md work --backup
# Auto-rename if conflict
upload_to_obsidian.sh file.md personal --rename
```
## Vault Configuration
**CRITICAL RULE**: When no vault is explicitly specified by the user, files MUST be uploaded to the `main` vault only. Do NOT assume or invent other vault names.
### Understanding Vault Structure
The MinIO obsidian bucket contains Obsidian vaults as top-level directories:
- **Bucket root**: `minio/obsidian/`
- **Vaults**: Each top-level directory is a separate Obsidian vault (e.g., `main/`, `journal/`, `work/`)
- **Files uploaded to**: `minio/obsidian/{vault-name}/{filename}`
### Vault Selection Behavior
- **No vault specified**: Upload to `main` vault (DEFAULT - use this unless user explicitly requests otherwise)
- **Specific vault specified**: Use the exact vault name provided by the user (e.g., `journal`, `work-notes`, `personal`)
- **Nested directories**: If a vault name contains slashes, it will be normalized (e.g., `notes/journal` becomes `notes/journal/`)
### Important Constraints
1. **Never assume vaults**: If the user doesn't specify a vault, always use `main`
2. **User intent only**: Only use non-default vaults when the user explicitly names them
3. **Vault validation**: The script automatically normalizes paths and appends the filename
### Examples
- User says "upload file.md" → Upload to `main` vault
- User says "upload to my journal vault" → Upload to `journal` vault
- User says "upload to work-notes" → Upload to `work-notes` vault
## Workflow
1. **Verify file exists** - Check that the source file is accessible
2. **Determine target vault** - Use specified vault name or default to `main`
3. **Check for conflicts** - Detect if file already exists in target vault
4. **Resolve conflict** - Prompt user or use specified option to handle conflict
5. **Upload with mc** - Execute `mc cp` command to transfer file
6. **Confirm success** - Verify upload completed and report target location
## Error Handling
The script will:
- Exit with error if file doesn't exist
- Exit with error if no file argument provided
- Propagate any mc command failures
## Resources
### scripts/upload_to_obsidian.sh
Bash script that handles the upload process. Validates inputs, constructs the target vault path, and executes the mc copy command.
**Key features:**
- Default to `main` vault when no vault name specified
- Support vault names with proper path normalization
- Clear error messages for invalid inputs
- Success confirmation with source and target paths