Skip to main content

文件外链生成工具

Project description

sxyz

集成多个后端的文件外链生成工具。

可以用来做什么?

这个工具可以通过统一的方式将你的文件上传到各种平台上,并生成外链。可以用作图床等。

目前支持的后端

  • 阿里OSS
  • 七牛对象存储
  • gitee

环境需求

  • Python 3.5+

用法

  1. 使用pip安装
pip install sxyz
  1. 配置后端

工具支持多个上传后端,每个后端有不同的配置。

首先执行sxyz config -d > sxyz.json生成默认的配置文件;然后编辑这个文件以配置你想要使用的后端。

  • 阿里OSS

进入阿里OSS的管理界面,选择一个Bucket,就可以看到所需的信息。

{
    "oss": {
        # bucket的外网域名,可以使用绑定的域名;如果不使用自己的域名,可以不填,之后会自动生成
        "domain": null,
        # bucket的名字
        "bktname": null,
        # bucket的地域节点(外网访问)
        "endpoint": null,
        # 阿里云的access_key,鼠标放在自己的头像上面可以看到
        "access_key": null,
        # 阿里云的secret,和access_key在一起
        "secret": null,
        # 是否使用https,可在bucket概览信息中查看域名是否支持https
        "https": false
    }
}
  • 七牛对象存储

进入七牛对象存储的管理界面,获取以下字段的值。

{
    "qiniu": {
        # 域名
        "domain": null,
        # bucket的名字
        "bktname": null,
        # 七牛云的access_key,在密钥管理处可以找到
        "access_key": null,
        # 七牛云的secret_key,和access_key在一起
        "secret": null,
        # 是否使用https
        "https": false
    }
}
  • gitee

这个相对简单,在gitee中新增一个仓库就可以使用。

{
    "gitee": {
        # 在用户中心的私人令牌处可以找到
        "access_token": null,
        # 你的用户名,点进你的一个仓库,仓库的url构成就是`https://gitee.com/你的用户名/你的仓库名`
        "username": null,
        # 要使用的仓库名
        "repo": null
    }
}

你也可以通过python sxyz.py config -k KEY -v VALUE子命令来配置各个字段。
对于通用配置,KEY就是配置项的名字;对于各个模块的配置,要以模块名:作为前缀。
比如,要配置默认的后端,也就是通用配置的default_backend项,那么使用-k default_backend -v oss的组合;又比如,要配置oss的domain项,则使用-k oss:domain -v DOMAIN

  1. 上传你的第一个文件
sxyz upload YOUR_FILE --backend gitee --init-backend

默认只支持几种常见的图片格式,要增加其他格式,需要在sxyz.json中配置valid_filetype项,内容为文件的mime字符串。在Linux可以使用xdg-mime query filetype YOUR_FILE获取。

oss和qiniu后端支持定时过期,过期后自动删除,使用--expired_days选项指定,过期时间可选项由配置文件中expired_days_options项指定。为0表示永不过期。

需要注意的是,有的后端在第一次上传的时候需要做一些初始化(目前只有阿里OSS),比如设置文件过期规则等。所以在第一次上传的时候记得加上--init-backend选项。

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

sxyz-0.1.post1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

sxyz-0.1.post1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file sxyz-0.1.post1.tar.gz.

File metadata

  • Download URL: sxyz-0.1.post1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.1

File hashes

Hashes for sxyz-0.1.post1.tar.gz
Algorithm Hash digest
SHA256 685452b89eeb9dbd9c0cf409cae54b63b5c614fab67177102b1bc745137a6193
MD5 73a8e0922d26d4f6982f5d3deb15fcd0
BLAKE2b-256 d0d2150eab932997e440517e1e268dcd3163ebcc2996f4e3901ba294faea868a

See more details on using hashes here.

File details

Details for the file sxyz-0.1.post1-py3-none-any.whl.

File metadata

  • Download URL: sxyz-0.1.post1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.5.1

File hashes

Hashes for sxyz-0.1.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 81172c48c9c48b71f9d0f768a18b2e660ff018b879b020301c7b620817f95415
MD5 48e7375ab34eb4442c81767bf62def88
BLAKE2b-256 720f93d2589043853e76ebbf3f9328256b94b1de79f237c7041cef38a26245b0

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