zoukankan      html  css  js  c++  java
  • 七牛云图床存储+Alfread工作流+使用QSHELL


    layout: post
    title: 七牛云图床存储+Alfread工作流+使用QSHELL

    来源:http://www.cnblogs.com/cmi-sh-love/p/8901620.html

    七牛云图床存储+Alfread工作流+使用QSHELL

    使用markdown最头疼的问题就是贴图问题。有多种方式来上传图片到图床,并获得外链的方面。而我们所希望最便捷以及最自然的方式就是,截取图片,然后粘贴进MarkDown编辑器的时候就自动上传到图床并且完成Markdown图片格式的编写。简单来说就是希望粘贴的时候就像粘贴图片到word一样,然后这些图片又是基于外链的,可以在任何有互联网的地方显示出来。

    准备工作

    大体可以分为三个部分:
    1.七牛云的配置
    2.qshell的配置
    3.Alfread的配置

    1.七牛云的配置

    1.1 注册

    如果还没有七牛云存储的账号,可以自行前往官网申请账号。提供10G的免费存储空间,每个月10G的下载流量、10万次PUT/DELETE请求、100万次GET请求。注册大家都会就不说了。

    1.2 新建空间与设置样式




    在样式里面可以新建多种样式,来控制图片大小,毕竟markdown语法不能控制图片大小

    1.3新建一个密匙用于qshell访问

    在个人面板点击密钥管理

    新建一个密钥,包含AccessKey/SecretKey,后面配置qshell需要用到

    2.qshell的配置

    到https://developer.qiniu.com/kodo/tools/1302/qshell下载QSHELL,下载mac版本后重命名为qshell

    新建目录用于放置配置文件以及数据文件如下:

    修改qshell文件的权限,使他成为可执行文件
    chmod 755 /User/apple/Download/qshell
    并将qshell文件放置在CLI目录下,并在CLI目录创建conf.json配置文件,内容如下:

    {
      "src_dir":"/Users/think/QiNiu/Data/",##本地图片数据目录
      "bucket":"markdownImage",##七牛云空间名称
      "rescan_local":true,
      "check_exists":true,
      "check_hash":true,
      "check_size":true
    }
    

    配置qshell密钥,在CLI目录下打开终端,使用命令设置密钥

    qshell account [AccessKey] [SecretKey]
    例如:qshell account kdajfiaifsanmflkwajfoiwr _fdaskrlakkkdasfanjjjj

    • 其中[AccessKey]和[SecretKey]为上面我们生成的密钥.
    • 配置 qshell 完毕后会生成 ~/.qshell 文件夹,其中 account.json 文件保存了 AccessKey 和 SecretKey 信息。

    3.Alfread的配置

    下载Alfred安装包并安装, 需要购买 Powerpack 才能解锁 workflows 功能,或者自行收索和谐版。
    下载工作流:百度云盘 密码:q18a
    导入之后修改脚本。

    脚本内容如下。

    
    property fileTypes : {¬
        {«class PNGf», ".png"}, ¬
        {JPEG picture, ".jpg"}}
    on getType()
        repeat with aType in fileTypes
            repeat with theInfo in (clipboard info)
                if (first item of theInfo) is equal to (first item of aType) then return aType
            end repeat
        end repeat
        return missing value
    end getType
    set theType to getType()
    if theType is not missing value then
        set filePath to "/Users/think/QiNiu/Data/" --这里换成你自己放置图片的路径
        set fileName to do shell script "date "+%Y%m%d%H%M%S" | md5" --用当前时间的md5值做文件名
        if fileName does not end with (second item of theType) then set fileName to (fileName & second item of theType as text)
        set markdownUrl to "![](http://p7iq38s6i.bkt.clouddn.com/" & fileName & "-480p)" --这里是你的七牛域名和设置的图片样式
        set filePath to filePath & fileName
        try
            set imageFile to (open for access filePath with write permission)
            set eof imageFile to 0
            write (the clipboard as (first item of theType)) to imageFile
            close access imageFile
            set the clipboard to markdownUrl
            try
                tell application "System Events"
                    keystroke "v" using command down
                end tell
            end try
            do shell script "/Users/think/QiNiu/CLI/qshell qupload /Users/think/QiNiu/CLI/conf.json" 
        on error
            try
                close access imageFile
            end try
            return ""
        end try
    else
        return ""
    end if
    

    需要修改如下地方
    set filePath to "/Users/think/QiNiu/Data/" --这里换成你自己放置图片的路径
    set markdownUrl to "![](http://p7iq38s6i.bkt.clouddn.com/" & fileName & "-480p)" --这里是你的七牛域名和设置的图片样式,若没有样式使用set markdownUrl to "![](http://p7iq38s6i.bkt.clouddn.com/" & fileName & ")"
    do shell script "/Users/think/QiNiu/CLI/qshell qupload /Users/think/QiNiu/CLI/conf.json"
    修改之后保持,并为工作流添加快捷键。粘贴的时候使用快捷键粘贴即可

  • 相关阅读:
    Openrasp源码分析
    feifeicms后台任意文件读取
    python之迭代器和生成器
    java之导入excel
    jquery单击事件的写法
    java之高效操作文件
    多条件搜索优化sql
    java之代码复用
    java之接口文档规范
    eclipse之常用快捷键
  • 原文地址:https://www.cnblogs.com/cmi-sh-love/p/8901620.html
Copyright © 2011-2022 走看看