Skip to main content

deeru七牛插件

Project description

DeerU七牛插件

安装

pip install deeru-qiniu

使用

  1. 运行初始化命令

    python manage.py init_qiniu

    根据提示进行配置, 你也可以跳过此步,在admin的 “配置” 中添加名为 “七牛配置” 的配置,配置内容为:

    {
        'access_key': 'access_key',
        'secret_key': 'secret_key',
        'bucket_name': '空间名',
        'media_pre':'媒体文件前缀(可为空)',
        'static_pre': '静态文件前缀(可为空)'
    }

    或是在 settings_local.py 中添加如下配置:

    QINIU = {
            'access_key': 'access_key',
            'secret_key': 'secret_key',
            'bucket_name': '空间名',
            'media_pre':'媒体文件前缀(可为空)',
            'static_pre': '静态文件前缀(可为空)'
            }
  2. 修改settings

    settings_local.pyCUSTOM_APPS 中添加app, 修改或添加 STATIC_URLMEDIA_URL 内容为七牛的域名,如果你设置了前缀,需要加上前缀

    CUSTOM_APPS = [
        'deeru_qiniu.apps.DeeruQiniuConfig'
    ]
    
    STATIC_URL='http://xx.bkt.clouddn.com/你的前缀/'
    MEDIA_URL='http://xx.bkt.clouddn.com/你的前缀/'
  3. 上传文件

    运行命令上传文件

    # 上传媒体文件
    python manage.py upload_qiniu --type media
    
    # 上传静态文件,上传静态文件前先运行collectstatic命令
    python manage.py collectstatic
    python manage.py upload_qiniu --type static

    若有相同名字的文件会上传失败,可用删除命令删除之前上传的文件

命令

删除命令

会删除所有媒体文件或静态文件,不支持单个文件删除,删除单个文件在七牛后台中自行删除

# 上传媒体文件
python manage.py delete_qiniu [--type (media|static) ]

配置说明

media_pre ,static_pre

url的前缀,可为空,建议设置防止与空间中的旧文件冲突

其他

如果文章中已经插入了图片,代理媒体文件会导致文章中的图片失效,需要重新编辑文章

license

GUN V3.0

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

deeru-qiniu-1.0.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

deeru_qiniu-1.0.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file deeru-qiniu-1.0.0.tar.gz.

File metadata

  • Download URL: deeru-qiniu-1.0.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for deeru-qiniu-1.0.0.tar.gz
Algorithm Hash digest
SHA256 036ec19acd2c0979c7d59c702556e47e597b72d8dbb7ab37d24db16d2b398235
MD5 70040d713ef8a4a4205e5d5baa5bd5ea
BLAKE2b-256 ef0e3f40acb3e7a5eadbc734fd281cc614c5df932d90458209bf437fde73619e

See more details on using hashes here.

File details

Details for the file deeru_qiniu-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for deeru_qiniu-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b1be697acfeb449b9687e24c61dbe13c3f05e54c8aaba934c67e5d9e85fc320
MD5 9bcf63b14e0f9329cc22ef9af16b691e
BLAKE2b-256 51b1fe8816a54fdac5ad41cec0bddcbb4a7aea86bdeee4c16f222912fb67be51

See more details on using hashes here.

Supported by

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