文档

命令参考

AnyToURL CLI 全部命令详解 — upload、text、url、whoami 和 config。

全局选项

所有命令均支持以下参数:

参数 说明
-u, --api-url <url> 覆盖已配置的 API 地址
-k, --api-key <key> 覆盖已配置的 API 密钥
-q, --quiet 仅输出 URL(每行一个)
-j, --json 以 JSON 格式输出

upload

上传一个或多个文件。支持本地文件、通配符和 stdin。

anytourl upload <files...>

示例

# 单个文件
anytourl upload screenshot.png

# 多个文件
anytourl upload file1.txt file2.pdf image.jpg

# 从 stdin 读取
cat photo.png | anytourl upload -
echo "hello" | anytourl upload --filename hello.txt

# 安静模式 — 仅返回 URL
anytourl upload photo.png -q

选项

参数 说明
--filename <name> 为 stdin 输入指定文件名

JSON 输出

使用 -j 时,每个结果包含:

字段 类型 说明
id string 唯一文件 ID
url string 分享链接
key string 文件 key
filename string 原始文件名
size number 文件大小(字节)
type string 文件类型
zone string 存储区域
expiresAt string | null 过期时间(永久则为 null)
permanent boolean 是否永久保存
deduped boolean 是否去重

text

创建文本粘贴,支持内联文本、文件和 stdin。

anytourl text [options]

示例

# 内联文本
anytourl text -c "Hello, world!"

# 从文件读取
anytourl text -f notes.md

# 从 stdin 读取
cat log.txt | anytourl text
echo "quick note" | anytourl text -t "My Note"

# JSON 输出
anytourl text -c "debug data" -j

选项

参数 说明
-c, --content <text> 要粘贴的文本内容
-f, --file <path> 从文件读取内容
-t, --title <title> 设置粘贴标题

JSON 输出

字段 类型 说明
id string 唯一粘贴 ID
url string 分享链接
filename string 生成的文件名
size number 内容大小(字节)
type string 文件类型
contentType string MIME 类型

url

缩短 URL。

anytourl url <url>

示例

# 缩短链接
anytourl url https://example.com/very/long/path/to/page

# 仅获取短链
anytourl url https://example.com/long -q

# JSON 输出
anytourl url https://example.com/long -j

JSON 输出

字段 类型 说明
id string 唯一 ID
url string 短链接
shortUrl string 短链接(别名)
shortCode string 短码标识
originalUrl string 原始长链接

whoami

显示账户信息、套餐和配额使用情况。

anytourl whoami

JSON 输出

字段 类型 说明
user.name string 账户名称
user.email string 账户邮箱
plan.displayName string 当前套餐名称
quota.storage object 存储用量(usedlimit、格式化版本)
quota.monthlyUpload object 月上传用量
quota.bandwidth object 带宽用量
features object 功能标记(apiAccesscustomShortLinks 等)
fileRetention.hours number | null 文件保留时长
fileRetention.permanent boolean 是否永久保存

config

管理 CLI 配置。设置存储在 ~/.anytourl

anytourl config <subcommand>

子命令

# 设置值
anytourl config set apiUrl https://anytourl.com
anytourl config set apiKey sk-your-api-key

# 获取值
anytourl config get apiKey

# 列出所有配置
anytourl config list

# 删除某个 key
anytourl config delete apiKey

# 清除所有配置
anytourl config clear

可用的 key:apiUrlapiKey


集成模式

脚本中捕获 URL

URL=$(anytourl upload report.pdf -q)
echo "Report uploaded: $URL"

CI/CD 流水线

# 上传构建产物
anytourl upload dist/*.js -q -k "$ANYTOURL_API_KEY" -u https://anytourl.com

管道链

# 生成 → 上传 → 通知
tar czf - ./logs | anytourl upload --filename logs.tar.gz -q | xargs -I{} curl -X POST "$WEBHOOK" -d '{"url":"{}"}'

npx 一次性使用

无需全局安装:

npx anytourl upload file.txt -k sk-your-key -u https://anytourl.com