Uploads/README.md
2026-04-23 15:46:26 +07:00

2.8 KiB

Typora Uploads

This repository is used to store images uploaded from Typora and serve them via raw URLs.


📌 Overview

When you paste an image into Typora:

  1. The image is copied into this repository
  2. It is committed and pushed to remote (Gitea)
  3. A raw URL is generated
  4. Typora replaces the local image with that URL

🚀 Setup (First Time Only)

Clone repository

git clone https://git.tltdb.com/Typora/Uploads.git ~/typora-uploads
cd ~/typora-uploads

⚠️ Do NOT run git init. Always use git clone.


Setup authentication

Create .netrc:

nano ~/.netrc
machine git.tltdb.com
login tltdb
password YOUR_TOKEN_HERE
chmod 600 ~/.netrc

Setup upload script

Create script:

mkdir -p ~/bin
nano ~/bin/typora-gitea-upload.sh

Paste your upload script, then:

chmod +x ~/bin/typora-gitea-upload.sh

Configure Typora

Preferences → Image

  • When Insert Local Images → Upload Image
  • Image Uploader → Custom Command

Command:

/Users/YOUR_USERNAME/bin/typora-gitea-upload.sh

🖥️ Using on Multiple Computers

On any new machine:

git clone https://git.tltdb.com/Typora/Uploads.git ~/typora-uploads
cd ~/typora-uploads

Then repeat:

  • authentication setup (~/.netrc)
  • upload script setup
  • Typora configuration

🔁 Daily Workflow

Before using Typora:

cd ~/typora-uploads
git pull origin main

After uploading images:

git push origin main

⚠️ Conflict Prevention

If using multiple devices:

  • Always run git pull before uploading
  • Avoid working offline too long

If conflict occurs:

git pull --rebase origin main

Add auto-sync to your script:

git pull --rebase origin main >/dev/null 2>&1 || true

📂 Repository Structure

Uploads/
├── README.md
└── uploads/
    └── YYYY/
        └── MM/
            ├── image-1.png
            └── image-2.jpg

🌐 Image URL Format

https://git.tltdb.com/Typora/Uploads/raw/branch/main/uploads/YYYY/MM/filename.png

🔒 Notes

  • Use public repo if images must be accessible everywhere
  • Do NOT embed token in Git remote URL
  • Prefer .netrc for authentication

🧯 Troubleshooting

Remote rejected (non-fast-forward)

git pull --rebase origin main
git push

Authentication failed

  • Check ~/.netrc
  • Verify token permissions

Script not working in Typora

  • Check script path
  • Ensure executable (chmod +x)
  • Test manually:
~/bin/typora-gitea-upload.sh "/path/to/image.png"

Key Rule

git clone   # correct
git init    # wrong (for this project)