Skip to main content

tool for uploading typora images to qcloud cos

Project description

为什么

通过 Typora QCloud Cos 将图片上传到腾讯云对象存储并得到图片外链,可以将 Markdown 文本和图片存储解耦,使得可以在任何地方浏览 Markdown 并且正常显示图片。

Typora

腾讯云对象存储定价

如何使用

安装:

下载 Python

# 安装 Python
# 安装 typora_cos
pip install -U typora_cos

创建存储桶:访问权限需要设置成 公有读私有写

image-20200922200543157

配置:

python -m typora_cos.qcloud --init

# 已生成配置文件,请继续完成配置: C:\Users\liaoz\.typora_cos\config.xml

https://console.cloud.tencent.com/cam/capi 获取 SecretIdSecretKey

https://console.cloud.tencent.com/cos5/bucket 创建存储桶并得到存储桶名称 bucket 和 所属区域 region

image-20200922200904022

从命令行上传图片:

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
image-20200922185842737

特性:

  • 支持本地图片和网络图片上传(将图片复制并粘贴到 typora)
  • 通过图片字节流识别图片格式
  • 通过 md5 避免重复上传图片

已知问题:

  • 网络图片的URL不能包含请求参数(不能包含 & 字符)

版本演进

版本 描述 进度
v1 基本功能实现
v2 重构 *
v3 命令行接口
v4 多线程

设计

流程:

  1. 输入一个或多个路径
  2. 将路径转换成字节流
  3. 将字节流抽象成对象存储文件类
  4. 执行上传操作,返回 URL

设计模式:策略模式+简单工厂方法、外观模式、简单工厂方法

其他:配置和代码解耦

image-20200923151137420

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typora_cos-2.0.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typora_cos-2.0.1-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file typora_cos-2.0.1.tar.gz.

File metadata

  • Download URL: typora_cos-2.0.1.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

Hashes for typora_cos-2.0.1.tar.gz
Algorithm Hash digest
SHA256 cf0976c3860181abfcfcc1541cef600aa8fd2e695e00d78159cb924e639cb18b
MD5 6c9edcc6125ae0109158361635bd02c5
BLAKE2b-256 2341ff057552f62d7ca62f48a7bb283ab7a525180f7b4774b749ae0b01c11f00

See more details on using hashes here.

File details

Details for the file typora_cos-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: typora_cos-2.0.1-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

Hashes for typora_cos-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0f22de68f464137de09d951c0ab44bda1ba1db12390dacb464b56ef0d13a5d1d
MD5 5570c625ecacb1bd1433746e1005002b
BLAKE2b-256 6f21a91569bbb87038fc2a24642309f60ab180b76062b316efa4ef039fc1a707

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page