Markdown image hosting: local i/ folder vs Cloudflare R2 and S3
Every image pasted into a Markdown note lives in one of two places: a local i/ subfolder beside the .md file, or an https:// object storage bucket such as Cloudflare R2 or Amazon S3. Keep images in the local i/ folder for private notes, offline access, and zero cloud maintenance; switch to S3 or R2 when notes become blog posts, newsletters, or GitHub issues where local paths cannot follow the text. MiaoYan supports both natively on Mac, iPhone, and iPad without a separate uploader app, falling back to the local i/ file whenever a network upload fails.
Local i/ folder vs S3 and R2 object storage
Where images belong depends on whether your Markdown stays personal or goes to the web:
| Dimension | Local i/ subfolder |
Cloudflare R2 or Amazon S3 |
|---|---|---|
| Offline reading | Always works without Wi-Fi | Requires internet unless cached |
| Cross-device sync | Syncs alongside notes via iCloud Drive or folder sync | .md files stay tiny; devices load https:// URLs |
| Web publishing | Needs separate image upload or self-contained HTML/PDF export | Markdown pastes directly into any CMS, repo, or editor |
| Durability | Lasts as long as your folder backups | Depends on keeping your bucket and custom domain live |
| Cost | Uses local disk and cloud drive quota | R2 has $0 egress fees and a 10 GB monthly free tier; S3 bills storage and egress |
As explained in Markdown image syntax: insert, resize and fix paths, MiaoYan defaults to local storage: pasting or dragging an image writes <note-folder>/i/<filename> and inserts , while PDFs and other files stay local in files/. For local-first Markdown notes you never paste into a web CMS, local i/ folders are the most durable option.
For public writing, Cloudflare R2 has largely replaced classic Amazon S3 for personal Markdown image hosting because R2 implements the S3 API with zero egress bandwidth fees, plus a free monthly tier of 10 GB standard storage, one million Class A writes, and ten million Class B reads (per Cloudflare's R2 pricing page; check current terms on Cloudflare's site).
Setting up Cloudflare R2 or Amazon S3 in MiaoYan
First create two things in your provider console: a bucket-scoped S3 API key pair (Access Key ID and Secret Access Key), and a public read domain attached to that bucket, such as https://img.example.com. Prefer your own custom domain over Cloudflare's rate-limited r2.dev development URL.
On Mac, press ⌘, to open Settings, pick Editor, and set Image Upload to S3 / R2 (use Set Up later to edit). On iPhone and iPad, open Settings > Image Upload and select S3 or R2:
S3 API / Endpoint : https://<account-id>.r2.cloudflarestorage.com/<bucket>
Access Key ID : <your-bucket-scoped-access-key-id>
Secret Access Key : <your-secret-access-key>
Public URL : https://img.example.com
There are no extra Region, Bucket, or Path Style switches because MiaoYan's S3UploadConfig parses them straight from S3 API (labeled Endpoint on iPhone and iPad):
- Cloudflare R2: Paste
https://<account-id>.r2.cloudflarestorage.com/<bucket>. MiaoYan extracts<bucket>from the path and signs with regionauto. - Amazon S3: Paste either virtual-hosted (
https://my-notes.s3.us-west-2.amazonaws.com) or path-style (https://s3.eu-central-1.amazonaws.com/my-notes) URLs; MiaoYan reads both bucket and region automatically, defaulting tous-east-1on global hosts. - MinIO, Backblaze B2, and Wasabi: Paste
https://host/<bucket>. Region-shaped host labels use that region and custom hosts useus-east-1. On Mac, plainhttp://is blocked for internet hosts so credentials and images stay encrypted, while loopback and private LAN addresses (127.0.0.1,192.168.x.x,nas.local) remain allowed for local MinIO servers.
How MiaoYan signs, names, and verifies uploads
Built-in cloud uploaders have to avoid two classic failures: leaking secret keys into plain-text dotfiles, and deleting a local screenshot after a PUT succeeds into a private bucket whose public URL returns 404. MiaoYan's S3Uploader guards against both:
- Keychain secret storage. Endpoint, Access Key ID, and Public URL live in app preferences, while
Secret Access Keygoes exclusively into the macOS or iOS Keychain (kSecClassGenericPassword, scoped by bundle ID). Saving writes to the Keychain first and aborts if refused, never pairing a new endpoint with an old secret. - Hash-suffixed monthly keys. Pasted screenshots often share generic names like
image.png. MiaoYan hashes image bytes with SHA-256 and writesYYYY/MM/<stem>-<8-char-hash>.<ext>in UTC:
2026/11/architecture-flow-1a2b3c4d.png
-> https://img.example.com/2026/11/architecture-flow-1a2b3c4d.png
- SigV4
PUTplus a publicHEADcheck. After signing a path-stylePUTwithCryptoKit(AWS4-HMAC-SHA256) and receiving2xx, MiaoYan sends an HTTPHEADrequest to the resultingPublic URL. Only when that public URL also answers2xxdoes MiaoYan swapforand delete the local temporary copy. Offline on a plane or facing a misconfigured domain, the locali/image stays intact in your note.
When uPic, PicGo, Picsee, or PicList still fit on Mac
MiaoYan on Mac also supports uPic, PicGo, Picsee, and PicList. Use them when uploading to non-S3 destinations like GitHub repositories, SM.MS, Imgur, or Chevereto, or when running custom WebP compression plugins. PicGo and PicList communicate over local HTTP while running in the background, and uPic and Picsee run from /Applications. None of those external apps exist on iOS, whereas built-in S3 / R2 works identically across Mac, iPhone, and iPad.
Common setup errors and how to verify
- "Save" stays disabled. Ensure all four fields are filled and S3 API / Endpoint includes
/<bucket>rather than stopping at the host name. - "The public URL does not show the uploaded image. The local image was kept." Your bucket
PUTsucceeded, while theHEADcheck on Public URL failed. Make sure Public URL holds your public custom domain (https://img.example.com), not the privater2.cloudflarestorage.comAPI endpoint. SignatureDoesNotMatchorAccessDenied. Generate an S3 API key pair with Object Read & Write on that bucket rather than pasting a single Cloudflare bearer API token.
Paste a test screenshot, watch /i/... turn into https://.../2026/11/..., and open that URL in a private browser tab to confirm public read access. MiaoYan is on the App Store for Mac, iPhone, and iPad, with S3Uploader.swift open source on GitHub.
FAQ
Do S3 / R2 credentials sync automatically between Mac and iPhone?
No. Because Secret Access Key stays in each device's local Keychain with no MiaoYan account server, enter the four fields once on Mac and once in Settings > Image Upload on iPhone or iPad.
Does MiaoYan upload PDFs or videos dragged into a note?
No. Only attachments written to /i/ (images) go to the uploader; PDFs, archives, and videos remain local inside files/.
What happens when I paste an image while offline?
MiaoYan saves the image into i/ first, sees the upload fail, keeps the working  link and local file in place, and shows a notice that the local image was kept.
Can one note mix local /i/ images and S3 / R2 links?
Yes. MiaoYan resolves /i/... against the note's folder and fetches https:// URLs side by side in preview, PDF export, and HTML export.
