Dev.to CLI Image Uploads From Terminal
说明与用途
devpub CLI 现在支持从终端直接上传图片到 Dev.to,取代手动网页编辑器流程。
问题
The Forem API lacks an image upload endpoint, forcing users to manually upload images via the web editor and copy URLs into markdown.
结果
The PR by Harish added a robust image uploader that validates files locally, handles CSRF and session cookies, parses varied response shapes, and outputs URLs or markdown. This eliminates the manual upload workflow and integrates image handling into the devpub CLI.
工作流
- 1. Install devpub v0.3 via pip
- 2. Store browser session credentials in .devpub/.env (DEVPUB_SESSION_COOKIE and DEVPUB_CSRF_TOKEN)
- 3. Run
devpub upload <image>to upload and receive the URL - 4. Optionally use
--markdownto get a ready‑to‑paste markdown tag - 5. Paste the URL or markdown into the article markdown
证据
devpub upload cover.png
That one command now gives you this: ...
The /image_uploads endpoint requires:
- A
_Devto_Forem_Sessioncookie - A CSRF token
- An
Originheader matchinghttps://dev.to
Harish's PR added a proper module with clear boundaries...
- 记录日期: 2026-09-21T18:00:25.995Z