tool for uploading typora images to qcloud cos
Project description
为什么
通过 Typora QCloud Cos 将图片上传到腾讯云对象存储并得到图片外链,可以将 Markdown 文本和图片存储解耦,使得可以在任何地方浏览 Markdown 并且正常显示图片。
如何使用
安装:
# 安装 Python
# 安装 typora_cos
pip install -U typora_cos
创建存储桶:访问权限需要设置成 公有读私有写
配置:
python -m typora_cos.qcloud --init
# 已生成配置文件,请继续完成配置: C:\Users\liaoz\.typora_cos\config.xml
从 https://console.cloud.tencent.com/cam/capi 获取
SecretId和SecretKey从 https://console.cloud.tencent.com/cos5/bucket 创建存储桶并得到存储桶名称
bucket和 所属区域region
从命令行上传图片:
python -m typora_cos.qcloud https://www.python.org/static/img/python-logo.png
# 已成功上传:
# https://test-1253318070.cos.ap-nanjing.myqcloud.com/7cbb8b7f3ec73ce6716fedaa4d63f6ce.png
python -m typora_cos.qcloud C:\Users\liaoz\Pictures\mc.jpg
# 已成功上传:
# https://test-1253318070.cos.ap-nanjing.myqcloud.com/739d7e571980d16ad192ff72e4f2d5d9.jpeg
typora 设置:
文件 -> 偏好设置 -> 自定义命令 -> python -m typora_cos.qcloud
特性:
- 支持本地图片和网络图片上传(将图片复制并粘贴到 typora)
- 通过图片字节流识别图片格式
- 通过 md5 避免重复上传图片
已知问题:
- 网络图片的URL不能包含请求参数(不能包含
&字符)
版本演进
| 版本 | 描述 | 进度 |
|---|---|---|
| v0 | 基本功能实现 | |
| v1 | 重构 | * |
| v2 | 命令行接口 | |
| v3 | 多线程 |
设计
流程:
- 输入一个或多个路径
- 将路径转换成字节流
- 将字节流抽象成对象存储文件类
- 执行上传操作,返回 URL
设计模式:策略模式+简单工厂方法、外观模式、简单工厂方法
其他:配置和代码解耦
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file typora_cos-2.0.0.tar.gz.
File metadata
- Download URL: typora_cos-2.0.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9208dd4df5ad68b853e19b53b1cd96aa172064a9044881fdc50909e055139b1e
|
|
| MD5 |
8c2516fdd35ce0b6f80c300178e14fe0
|
|
| BLAKE2b-256 |
7f28319e3f8fa6637db95dd9ea8e0562da254591378d96d5b556ecf75656f3c6
|
File details
Details for the file typora_cos-2.0.0-py3-none-any.whl.
File metadata
- Download URL: typora_cos-2.0.0-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2134bb0542d7b797fe14539b75110dec2930a0d1d50a7ce6221edf04e94c3c3d
|
|
| MD5 |
3c3391788374c09936566d1d98dc5ccb
|
|
| BLAKE2b-256 |
2a7f1818dc469e45c64e6131b703ff684e4b8b887258d1fe3ea9b403131ff998
|