cos-uploader


Namecos-uploader JSON
Version 2.0.0rc3 PyPI version JSON
download
home_pagehttps://github.com/baobao1270/cos-uploader
SummaryCLI tool for uploading files to Tencent COS
upload_time2023-05-13 10:22:27
maintainer
docs_urlNone
authorJoseph Chris
requires_python>=3.8,<4.0
licenseMIT
keywords tencent-cos uploader
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # COS Uploader

跨平台的腾讯云对象存储上传工具

 - 支持 Windows、Linux、MacOS
 - 可以用于图片上传(图床)、文件分享等
 - 带有日志记录功能,可以查看上传历史
 - 支持通过系统自带的工具快速上传文件(Windows:「发送到」;MacOS:「快捷指令」)


## 安装
我们推荐使用 [pipx](https://pypa.github.io/pipx/) 安装 COS Uploader,请参见其官网来安装 pipx。

```bash
# 安装方法 1:使用 pipx 安装 (推荐)
pipx install cos-uploader

# 安装方法 2:使用 pip 安装
pip3 install cos-uploader

# 安装方法 3:手动创建虚拟环境安装 (可能会出现未经测试的问题)
mkdir -p ~/.cos-uploader/bin
python3 -m venv ~/.cos-uploader/venv
source ~/.cos-uploader/venv/bin/activate
pip install cos-uploader
ln -s ~/.cos-uploader/venv/bin/cos-uploader* ~/.cos-uploader/bin
echo 'export PATH="$PATH:$HOME/.cos-uploader/bin"' >> ~/.profile
```

## 使用
安装完成后,请运行 `cos-uploader-install` 来初始化配置,然后编辑 `~/.cos-uploader/config.toml` 来配置 COS Uploader。

请确保 `secret-id`、`secret-key`、`bucket`、`region` 配置正确,否则无法上传文件。

如果输入 `cos-uploader-install` 后提示找不到命令,可能是 PATH 环境变量没有生效或没有配置,请依次检查:
 - 重新启动当前 shell,如 `exec zsh` 或 `exec bash`
 - 重新启动当前终端,在 GUI 下应退出终端应用(iTerm2 下按 <kbd>Command ⌘</kbd> + <kbd>Q</kbd>、Windows Terminal 下关闭窗口)
 - 查看 PATH 变量
    - 使用 pipx,需要根据 pipx 的提示将 `~/.local/bin` 添加到 PATH
    - Windows 版的 Python 默认不会将 `Scripts` 添加到 PATH,需要手动添加。打开 [设置——系统——关于](ms-settings:about) 点击右侧「高级系统设置」,添加 `C:\Users\<用户名>\AppData\Roaming\Python\<Python版本>\Scripts` 到 PATH
    - 如果使用了手动创建虚拟环境安装(安装方法 3),请将 `~/.cos-uploader/bin` 添加到 PATH

配置完成后,可以使用 `cos-uploader` 命令来上传文件。

```bash
# 上传文件试试,测试配置是否正确
echo "Hello World" > hello.txt
cos-uploader hello.txt
```

### Windows 平台功能
在运行 `cos-uploader-install` 时,会自动创建「发送到」菜单项。

配置完成 `config.toml`后,在「资源管理器」中右键想要上传的文件,在菜单中选择「发送到」,然后选择「COS Uploader」即可上传该文件。

### MacOS 平台功能

请导入 [COS Uploader 快捷指令](https://www.icloud.com/shortcuts/76e95603ee464cddb0a7af9afe89c719)

导入完成后,请打开「快捷指令」App,选择左上角菜单中的「快捷指令——设置——高级」,勾选「允许运行脚本」。

配置完成 `config.toml` 后,在 Finder 中右键想要上传的文件,在菜单中选择「快速操作」,然后选择「COS Uploader」即可上传该文件。

## 查看历史
COS Uploader 会记录上传历史,可以通过 `cos-uploader-history` 命令来查看。输出记录按照时间戳降序排列。

`cos-uploader-history` 默认会输出全部记录,可以通过 `-n` 参数来限制输出的记录数量。

```bash
cos-uploader-history -n 10
```

COS Uploader 按月分割文件,文件日志格式为 `~/cos-uploader/history-yyyy-MM.ndjson`,其中 `yyyy-MM` 为年月。`cos-uploader-history` 仅输出当前月份的记录,可以通过 `-y`、`-m` 参数来指定时间。

```bash
cos-uploader-history -y 2023 -m 1
```

COS Uploader 使用 NDJSON 格式来记录上传历史,可以通过 `cos-uploader-history -r` 来查看原始记录。

```bash
cos-uploader-history -n 10 -r
```

### 优化海外使用体验
如果您上传文件的设备位于中国大陆境外,请修改 `config.toml` 如下:
```toml
oversea-upload = true
```

如果您的文件使用者位于中国大陆境外,请修改 `config.toml` 如下,并使用输出的 `Acc URL` 来访问文件。注意:需要在腾讯云控制台开启该 bucket 的「加速域名」功能。
```toml
[domains]
enabled = ["accelerate"]  # 在此处添加 accelerate,原来的可以删掉也可以保留
```

COS Uploader 默认在 URL 格式化的时候,使用 UTC 时间。如果需要使用本地时间(使用上传设备的系统时间),请修改 `config.toml` 如下:
```toml
utc-time = false
```

## 构建
COS Uploader 使用 Poetry 构建。请先安装 Poetry,然后执行以下命令:

```bash
git clone https://github.com/baobao1270/cos-uploader.git
cd cos-uploader
poetry install
```

要发布到 PyPI,请执行以下命令:

```bash
poetry publish --build
```

## 许可
COS Uploader 使用 MIT 协议

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/baobao1270/cos-uploader",
    "name": "cos-uploader",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "tencent-cos,uploader",
    "author": "Joseph Chris",
    "author_email": "joseph@josephcz.xyz",
    "download_url": "https://files.pythonhosted.org/packages/72/e1/e8f1688574a016d2fdc1a251942d649f9f95c688bc618928a6308f081298/cos_uploader-2.0.0rc3.tar.gz",
    "platform": null,
    "description": "# COS Uploader\n\n\u8de8\u5e73\u53f0\u7684\u817e\u8baf\u4e91\u5bf9\u8c61\u5b58\u50a8\u4e0a\u4f20\u5de5\u5177\n\n - \u652f\u6301 Windows\u3001Linux\u3001MacOS\n - \u53ef\u4ee5\u7528\u4e8e\u56fe\u7247\u4e0a\u4f20\uff08\u56fe\u5e8a\uff09\u3001\u6587\u4ef6\u5206\u4eab\u7b49\n - \u5e26\u6709\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\uff0c\u53ef\u4ee5\u67e5\u770b\u4e0a\u4f20\u5386\u53f2\n - \u652f\u6301\u901a\u8fc7\u7cfb\u7edf\u81ea\u5e26\u7684\u5de5\u5177\u5feb\u901f\u4e0a\u4f20\u6587\u4ef6\uff08Windows\uff1a\u300c\u53d1\u9001\u5230\u300d\uff1bMacOS\uff1a\u300c\u5feb\u6377\u6307\u4ee4\u300d\uff09\n\n\n## \u5b89\u88c5\n\u6211\u4eec\u63a8\u8350\u4f7f\u7528 [pipx](https://pypa.github.io/pipx/) \u5b89\u88c5 COS Uploader\uff0c\u8bf7\u53c2\u89c1\u5176\u5b98\u7f51\u6765\u5b89\u88c5 pipx\u3002\n\n```bash\n# \u5b89\u88c5\u65b9\u6cd5 1\uff1a\u4f7f\u7528 pipx \u5b89\u88c5 (\u63a8\u8350)\npipx install cos-uploader\n\n# \u5b89\u88c5\u65b9\u6cd5 2\uff1a\u4f7f\u7528 pip \u5b89\u88c5\npip3 install cos-uploader\n\n# \u5b89\u88c5\u65b9\u6cd5 3\uff1a\u624b\u52a8\u521b\u5efa\u865a\u62df\u73af\u5883\u5b89\u88c5 (\u53ef\u80fd\u4f1a\u51fa\u73b0\u672a\u7ecf\u6d4b\u8bd5\u7684\u95ee\u9898)\nmkdir -p ~/.cos-uploader/bin\npython3 -m venv ~/.cos-uploader/venv\nsource ~/.cos-uploader/venv/bin/activate\npip install cos-uploader\nln -s ~/.cos-uploader/venv/bin/cos-uploader* ~/.cos-uploader/bin\necho 'export PATH=\"$PATH:$HOME/.cos-uploader/bin\"' >> ~/.profile\n```\n\n## \u4f7f\u7528\n\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8bf7\u8fd0\u884c `cos-uploader-install` \u6765\u521d\u59cb\u5316\u914d\u7f6e\uff0c\u7136\u540e\u7f16\u8f91 `~/.cos-uploader/config.toml` \u6765\u914d\u7f6e COS Uploader\u3002\n\n\u8bf7\u786e\u4fdd `secret-id`\u3001`secret-key`\u3001`bucket`\u3001`region` \u914d\u7f6e\u6b63\u786e\uff0c\u5426\u5219\u65e0\u6cd5\u4e0a\u4f20\u6587\u4ef6\u3002\n\n\u5982\u679c\u8f93\u5165 `cos-uploader-install` \u540e\u63d0\u793a\u627e\u4e0d\u5230\u547d\u4ee4\uff0c\u53ef\u80fd\u662f PATH \u73af\u5883\u53d8\u91cf\u6ca1\u6709\u751f\u6548\u6216\u6ca1\u6709\u914d\u7f6e\uff0c\u8bf7\u4f9d\u6b21\u68c0\u67e5\uff1a\n - \u91cd\u65b0\u542f\u52a8\u5f53\u524d shell\uff0c\u5982 `exec zsh` \u6216 `exec bash`\n - \u91cd\u65b0\u542f\u52a8\u5f53\u524d\u7ec8\u7aef\uff0c\u5728 GUI \u4e0b\u5e94\u9000\u51fa\u7ec8\u7aef\u5e94\u7528\uff08iTerm2 \u4e0b\u6309 <kbd>Command \u2318</kbd> + <kbd>Q</kbd>\u3001Windows Terminal \u4e0b\u5173\u95ed\u7a97\u53e3\uff09\n - \u67e5\u770b PATH \u53d8\u91cf\n    - \u4f7f\u7528 pipx\uff0c\u9700\u8981\u6839\u636e pipx \u7684\u63d0\u793a\u5c06 `~/.local/bin` \u6dfb\u52a0\u5230 PATH\n    - Windows \u7248\u7684 Python \u9ed8\u8ba4\u4e0d\u4f1a\u5c06 `Scripts` \u6dfb\u52a0\u5230 PATH\uff0c\u9700\u8981\u624b\u52a8\u6dfb\u52a0\u3002\u6253\u5f00 [\u8bbe\u7f6e\u2014\u2014\u7cfb\u7edf\u2014\u2014\u5173\u4e8e](ms-settings:about) \u70b9\u51fb\u53f3\u4fa7\u300c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u300d\uff0c\u6dfb\u52a0 `C:\\Users\\<\u7528\u6237\u540d>\\AppData\\Roaming\\Python\\<Python\u7248\u672c>\\Scripts` \u5230 PATH\n    - \u5982\u679c\u4f7f\u7528\u4e86\u624b\u52a8\u521b\u5efa\u865a\u62df\u73af\u5883\u5b89\u88c5\uff08\u5b89\u88c5\u65b9\u6cd5 3\uff09\uff0c\u8bf7\u5c06 `~/.cos-uploader/bin` \u6dfb\u52a0\u5230 PATH\n\n\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 `cos-uploader` \u547d\u4ee4\u6765\u4e0a\u4f20\u6587\u4ef6\u3002\n\n```bash\n# \u4e0a\u4f20\u6587\u4ef6\u8bd5\u8bd5\uff0c\u6d4b\u8bd5\u914d\u7f6e\u662f\u5426\u6b63\u786e\necho \"Hello World\" > hello.txt\ncos-uploader hello.txt\n```\n\n### Windows \u5e73\u53f0\u529f\u80fd\n\u5728\u8fd0\u884c `cos-uploader-install` \u65f6\uff0c\u4f1a\u81ea\u52a8\u521b\u5efa\u300c\u53d1\u9001\u5230\u300d\u83dc\u5355\u9879\u3002\n\n\u914d\u7f6e\u5b8c\u6210 `config.toml`\u540e\uff0c\u5728\u300c\u8d44\u6e90\u7ba1\u7406\u5668\u300d\u4e2d\u53f3\u952e\u60f3\u8981\u4e0a\u4f20\u7684\u6587\u4ef6\uff0c\u5728\u83dc\u5355\u4e2d\u9009\u62e9\u300c\u53d1\u9001\u5230\u300d\uff0c\u7136\u540e\u9009\u62e9\u300cCOS Uploader\u300d\u5373\u53ef\u4e0a\u4f20\u8be5\u6587\u4ef6\u3002\n\n### MacOS \u5e73\u53f0\u529f\u80fd\n\n\u8bf7\u5bfc\u5165 [COS Uploader \u5feb\u6377\u6307\u4ee4](https://www.icloud.com/shortcuts/76e95603ee464cddb0a7af9afe89c719)\n\n\u5bfc\u5165\u5b8c\u6210\u540e\uff0c\u8bf7\u6253\u5f00\u300c\u5feb\u6377\u6307\u4ee4\u300dApp\uff0c\u9009\u62e9\u5de6\u4e0a\u89d2\u83dc\u5355\u4e2d\u7684\u300c\u5feb\u6377\u6307\u4ee4\u2014\u2014\u8bbe\u7f6e\u2014\u2014\u9ad8\u7ea7\u300d\uff0c\u52fe\u9009\u300c\u5141\u8bb8\u8fd0\u884c\u811a\u672c\u300d\u3002\n\n\u914d\u7f6e\u5b8c\u6210 `config.toml` \u540e\uff0c\u5728 Finder \u4e2d\u53f3\u952e\u60f3\u8981\u4e0a\u4f20\u7684\u6587\u4ef6\uff0c\u5728\u83dc\u5355\u4e2d\u9009\u62e9\u300c\u5feb\u901f\u64cd\u4f5c\u300d\uff0c\u7136\u540e\u9009\u62e9\u300cCOS Uploader\u300d\u5373\u53ef\u4e0a\u4f20\u8be5\u6587\u4ef6\u3002\n\n## \u67e5\u770b\u5386\u53f2\nCOS Uploader \u4f1a\u8bb0\u5f55\u4e0a\u4f20\u5386\u53f2\uff0c\u53ef\u4ee5\u901a\u8fc7 `cos-uploader-history` \u547d\u4ee4\u6765\u67e5\u770b\u3002\u8f93\u51fa\u8bb0\u5f55\u6309\u7167\u65f6\u95f4\u6233\u964d\u5e8f\u6392\u5217\u3002\n\n`cos-uploader-history` \u9ed8\u8ba4\u4f1a\u8f93\u51fa\u5168\u90e8\u8bb0\u5f55\uff0c\u53ef\u4ee5\u901a\u8fc7 `-n` \u53c2\u6570\u6765\u9650\u5236\u8f93\u51fa\u7684\u8bb0\u5f55\u6570\u91cf\u3002\n\n```bash\ncos-uploader-history -n 10\n```\n\nCOS Uploader \u6309\u6708\u5206\u5272\u6587\u4ef6\uff0c\u6587\u4ef6\u65e5\u5fd7\u683c\u5f0f\u4e3a `~/cos-uploader/history-yyyy-MM.ndjson`\uff0c\u5176\u4e2d `yyyy-MM` \u4e3a\u5e74\u6708\u3002`cos-uploader-history` \u4ec5\u8f93\u51fa\u5f53\u524d\u6708\u4efd\u7684\u8bb0\u5f55\uff0c\u53ef\u4ee5\u901a\u8fc7 `-y`\u3001`-m` \u53c2\u6570\u6765\u6307\u5b9a\u65f6\u95f4\u3002\n\n```bash\ncos-uploader-history -y 2023 -m 1\n```\n\nCOS Uploader \u4f7f\u7528 NDJSON \u683c\u5f0f\u6765\u8bb0\u5f55\u4e0a\u4f20\u5386\u53f2\uff0c\u53ef\u4ee5\u901a\u8fc7 `cos-uploader-history -r` \u6765\u67e5\u770b\u539f\u59cb\u8bb0\u5f55\u3002\n\n```bash\ncos-uploader-history -n 10 -r\n```\n\n### \u4f18\u5316\u6d77\u5916\u4f7f\u7528\u4f53\u9a8c\n\u5982\u679c\u60a8\u4e0a\u4f20\u6587\u4ef6\u7684\u8bbe\u5907\u4f4d\u4e8e\u4e2d\u56fd\u5927\u9646\u5883\u5916\uff0c\u8bf7\u4fee\u6539 `config.toml` \u5982\u4e0b\uff1a\n```toml\noversea-upload = true\n```\n\n\u5982\u679c\u60a8\u7684\u6587\u4ef6\u4f7f\u7528\u8005\u4f4d\u4e8e\u4e2d\u56fd\u5927\u9646\u5883\u5916\uff0c\u8bf7\u4fee\u6539 `config.toml` \u5982\u4e0b\uff0c\u5e76\u4f7f\u7528\u8f93\u51fa\u7684 `Acc URL` \u6765\u8bbf\u95ee\u6587\u4ef6\u3002\u6ce8\u610f\uff1a\u9700\u8981\u5728\u817e\u8baf\u4e91\u63a7\u5236\u53f0\u5f00\u542f\u8be5 bucket \u7684\u300c\u52a0\u901f\u57df\u540d\u300d\u529f\u80fd\u3002\n```toml\n[domains]\nenabled = [\"accelerate\"]  # \u5728\u6b64\u5904\u6dfb\u52a0 accelerate\uff0c\u539f\u6765\u7684\u53ef\u4ee5\u5220\u6389\u4e5f\u53ef\u4ee5\u4fdd\u7559\n```\n\nCOS Uploader \u9ed8\u8ba4\u5728 URL \u683c\u5f0f\u5316\u7684\u65f6\u5019\uff0c\u4f7f\u7528 UTC \u65f6\u95f4\u3002\u5982\u679c\u9700\u8981\u4f7f\u7528\u672c\u5730\u65f6\u95f4\uff08\u4f7f\u7528\u4e0a\u4f20\u8bbe\u5907\u7684\u7cfb\u7edf\u65f6\u95f4\uff09\uff0c\u8bf7\u4fee\u6539 `config.toml` \u5982\u4e0b\uff1a\n```toml\nutc-time = false\n```\n\n## \u6784\u5efa\nCOS Uploader \u4f7f\u7528 Poetry \u6784\u5efa\u3002\u8bf7\u5148\u5b89\u88c5 Poetry\uff0c\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n\n```bash\ngit clone https://github.com/baobao1270/cos-uploader.git\ncd cos-uploader\npoetry install\n```\n\n\u8981\u53d1\u5e03\u5230 PyPI\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n\n```bash\npoetry publish --build\n```\n\n## \u8bb8\u53ef\nCOS Uploader \u4f7f\u7528 MIT \u534f\u8bae\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "CLI tool for uploading files to Tencent COS",
    "version": "2.0.0rc3",
    "project_urls": {
        "Documentation": "https://github.com/baobao1270/cos-uploader/blob/main/README.md",
        "Homepage": "https://github.com/baobao1270/cos-uploader",
        "Repository": "https://github.com/baobao1270/cos-uploader.git"
    },
    "split_keywords": [
        "tencent-cos",
        "uploader"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "33566c671e17270cf63e5116dc51aa004506cc4b2befd3f7aabf46c46e3c899e",
                "md5": "c78862b8c31c4f543a5272aedd93eaf0",
                "sha256": "7460a5896841140f51ad9f6e043e0c6dc9a94ff46dfd5cb4019afd0f1d70e883"
            },
            "downloads": -1,
            "filename": "cos_uploader-2.0.0rc3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c78862b8c31c4f543a5272aedd93eaf0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 9061,
            "upload_time": "2023-05-13T10:22:25",
            "upload_time_iso_8601": "2023-05-13T10:22:25.827381Z",
            "url": "https://files.pythonhosted.org/packages/33/56/6c671e17270cf63e5116dc51aa004506cc4b2befd3f7aabf46c46e3c899e/cos_uploader-2.0.0rc3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "72e1e8f1688574a016d2fdc1a251942d649f9f95c688bc618928a6308f081298",
                "md5": "c9dbf560d7687553faf96b57ce93b6c2",
                "sha256": "358546d8170cc280c6ad8d5faef8fbd5224382be98f0db050570e2ed993e06fb"
            },
            "downloads": -1,
            "filename": "cos_uploader-2.0.0rc3.tar.gz",
            "has_sig": false,
            "md5_digest": "c9dbf560d7687553faf96b57ce93b6c2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 7313,
            "upload_time": "2023-05-13T10:22:27",
            "upload_time_iso_8601": "2023-05-13T10:22:27.341832Z",
            "url": "https://files.pythonhosted.org/packages/72/e1/e8f1688574a016d2fdc1a251942d649f9f95c688bc618928a6308f081298/cos_uploader-2.0.0rc3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-13 10:22:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "baobao1270",
    "github_project": "cos-uploader",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cos-uploader"
}
        
Elapsed time: 0.12187s