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-20200923154820861

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.2.tar.gz (7.6 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.2-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typora_cos-2.0.2.tar.gz
  • Upload date:
  • Size: 7.6 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.2.tar.gz
Algorithm Hash digest
SHA256 5e77bc5a1130b352cd836706bd427b1bac4fedf743623e12ef359b5d0fff2fa8
MD5 1091a321b3a3376b1663d1cc72d36b06
BLAKE2b-256 9f8cd9790c8e848c79406f865d2c9e902c6525a0c29021745e80f767d78d0743

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typora_cos-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8eefbd330916f90cd89324b5e0b1f339e369fcb5af3fbfa1ba2651dda65de93a
MD5 933525c5c3c534b9b64a3c65194bbf46
BLAKE2b-256 512d109edc7f592ea1729d1d1835665dffff166ad7951e2a6d3b47b14d75e71d

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